discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Discuss-gnuradio] working SSRP


From: Berndt Josef Wulf
Subject: Re: [Discuss-gnuradio] working SSRP
Date: Wed, 22 Dec 2004 13:41:48 +1030
User-agent: KMail/1.7.1

On Wednesday 22 December 2004 10:48, Eric Blossom wrote:
> On Wed, Dec 22, 2004 at 10:43:15AM +1030, Berndt Josef Wulf wrote:
> > FYI:
> >
> > The following test provides the correct answer on NetBSD with
> > #define M_PI            3.14159265358979323846  /* pi */
> > from the math library header file (note the typecast to float).
>
> I've updated CVS with the explict float cast.  Can you please check.
>

This didn't work, however find changes below that will succeed in providing 
the expected answer:

----------------------------- gr_fxpt.h.diff -------------------------
--- gr_fxpt.h.orig      2004-12-22 13:34:43.000000000 +1030
+++ gr_fxpt.h   2004-12-22 13:38:54.000000000 +1030
@@ -46,7 +46,7 @@
   static gr_int32
   float_to_fixed (float x)
   {
-    return (gr_int32) ((float) (x * (TWO_TO_THE_31 / PI)));
+    return (gr_int32) ((float) x * TWO_TO_THE_31 / PI);
   }

   static float
----------------------------- gr_fxpt.h.diff -------------------------

I've rewritten the test program to make direct use of the float_to_fix() 
function, see below:

----------------------------- test.c -------------------------
#include <math.h>
#include <iostream>
#include <gr_fxpt.h>

int main(void)
{
  gr_int32 result;
  result = gr_fxpt::float_to_fixed((M_PI)/2);
  std::cout << result << std::endl;
  return 0;
}
----------------------------- test.c -------------------------


cheerio Berndt

Attachment: pgpxnSDgKDkvC.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]