discuss-gnuradio
[Top][All Lists]
Advanced

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

Re: [Discuss-gnuradio] gr_frequency_modulator_fc.cc: unknown function tr


From: kilian
Subject: Re: [Discuss-gnuradio] gr_frequency_modulator_fc.cc: unknown function trunc()
Date: Sun, 06 Mar 2005 23:17:55 -0500

Hi,

not having NetBSD available I can only show you what man trunc tells me
under Linux:
-----------------------------------------------------------
NAME
       trunc, truncf, truncl - round to integer, towards zero

SYNOPSIS
       #include <math.h>

       double trunc(double x);
       float truncf(float x);
       long double truncl(long double x);

       Compile with -std=c99; link with -lm.

DESCRIPTION
       These  functions  round x to the nearest integer not larger in
absolute
       value.

RETURN VALUE
       The rounded integer value.  If x is integral, infinite or NaN, x
itself
       is returned.

ERRORS
       None.

CONFORMING TO
       C99.

SEE ALSO
       ceil(3), floor(3), lrint(3), nearbyint(3), rint(3), round(3)

--------------------------------------------------------------------------

You may very well find truncf() under NetBSD although checking for it
here:

 http://netbsd.gw.com/cgi-bin/man-cgi?math+3+NetBSD-current

didn't help me find it. However there is rint() but it rounds to the
nearest integer. You could spin your own trunc() I suppose. 

Hm, I can't stop now I guess. 

This code:

#include <math.h>

int main(void)
{
  float a;
  
  printf("floor(0.6):%f\n",floor(0.6));
  printf("floor(-0.6):%f\n",floor(-0.6));
  printf("trunc(0.6):%f\n",trunc(0.6));
  printf("trunc(-0.6):%f\n",trunc(-0.6));

  a=-0.6;
  printf("a/fabs(a)*floor(fabs(a)):%f\n",a/fabs(a)*floor(fabs(a)));

}

gives:

floor(0.6):0.000000
floor(-0.6):-1.000000
trunc(0.6):0.000000
trunc(-0.6):-0.000000
a/fabs(a)*floor(fabs(a)):-0.000000

I may still be wrong though. It is also inefficient.


Regards,

Kilian







reply via email to

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