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: Berndt Josef Wulf
Subject: Re: [Discuss-gnuradio] gr_frequency_modulator_fc.cc: unknown function trunc()
Date: Tue, 8 Mar 2005 00:24:42 +1030
User-agent: KMail/1.7.2

G'day,

thanks for supplying the man page on trunc(). This function is indeed missing 
in NetBSD - not sure why.

Anyhow, I think I've found a solution that works and may be acceptable for 
inclusion into the source tree for platforms that lack this functionality. 
Find patch below that checks for trunc() and if not found includes a simple 
macro definition.

--- configure.ac.orig   2005-03-07 22:10:37.000000000 +1030
+++ configure.ac        2005-03-07 22:26:59.000000000 +1030
@@ -102,6 +102,7 @@
 AC_CHECK_LIB(m, sincosf,[AC_DEFINE([HAVE_SINCOSF],[1],[Define to 1 if your 
system has `sincosf'.])])
 AC_CHECK_LIB(m, sinf, [AC_DEFINE([HAVE_SINF],[1],[Define to 1 if your system 
has `sinf'.])])
 AC_CHECK_LIB(m, cosf, [AC_DEFINE([HAVE_COSF],[1],[Define to 1 if your system 
has `cosf'.])])
+AC_CHECK_LIB(m, trunc, [AC_DEFINE([HAVE_TRUNC],[1],[Define to 1 if your 
systemhas no `trunc'.])])

 GR_CHECK_SHM_OPEN

--- src/lib/general/gr_frequency_modulator_fc.cc.orig   2005-03-07 
22:17:55.000000000 +1030
+++ src/lib/general/gr_frequency_modulator_fc.cc        2005-03-07 
22:27:25.000000000 +1030
@@ -29,6 +29,9 @@
 #include <gr_sincos.h>
 #include <math.h>

+#ifndef HAVE_TRUNC
+#define trunc(x) (double) ((int) (x + (x >= 0.0 ? -0.5 : 0.5)))
+#endif

 gr_frequency_modulator_fc_sptr gr_make_frequency_modulator_fc (double 
sensitivity)
 {


73, Berndt
VK5ABN

On Mon, 7 Mar 2005 02:47 pm, kilian wrote:
> 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.
>




reply via email to

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