ts-7000
[Top] [All Lists]

Re: [ts-7000] Floating Point Functions

To:
Subject: Re: [ts-7000] Floating Point Functions
From: "Stephen Queen" <>
Date: Tue, 24 Apr 2007 06:38:47 -0600
Try adding to your code the following include statements:
#include <stdlib.h>
#include <math.h>

Then when you compile, use the following command:
gcc -o program_name program_name.c -lm -std=c99

As a note, be carefull about using the name "test" for a program. There is a shell built in named "test" which could run instead of the program you are expecting.

Stephen Queen

On 4/22/07, jywmpg <> wrote:

I cannot seem to get reasonable results from a couple of floating
point library functions and wonder what I am doing wrong. I am
running on a 7260 and get the same results whether I use the cross
compiler or compile natively.

Test program:
$ cat test.c
#include<stdio.h>
int main(int argc, char **argv)
{
double test = 432.123;
double testTrunc = trunc(test);
double testFloor = floor(test);
double testCeil = ceil(test);
fprintf (stderr, "test start: %.3f, test trunc: %.3f, test floor:
%.3f, test ceil: %.3f\n",
test, testTrunc, testFloor, testCeil);
exit(0);
}

$ gcc -o test test.c -lm
$ ./test
test start: 432.123, test trunc: 1081803255.000, test floor: 4095.000,
test ceil: 4095.000

gcc -v
Reading specs from /usr/lib/gcc-lib/arm-linux/3.3.5/specs
Configured with: ../src/configure -v
--enable-languages=c,c++,java,f77,pascal,objc,treelang --prefix=/usr
--mandir=/usr/share/man --infodir=/usr/share/info
--with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared
--enable-__cxa_atexit --with-system-zlib --enable-nls
--without-included-gettext --enable-clocale=gnu --enable-debug
--enable-java-gc=boehm --enable-java-awt=xlib --enable-objc-gc arm-linux
Thread model: posix
gcc version 3.3.5 (Debian 1:3.3.5-13)

Should this work?

Regards,

jw


__._,_.___


SPONSORED LINKS
Single board computer Hardware Computer running slow
Linux os Single board

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: =Email Delivery: Digest | m("yahoogroups.com?subject","ts-7000-fullfeatured");=Change Delivery Format: Fully Featured">Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | =Unsubscribe

__,_._,___
<Prev in Thread] Current Thread [Next in Thread>
Admin

Disclaimer: Neither Andrew Taylor nor the University of NSW School of Computer and Engineering take any responsibility for the contents of this archive. It is purely a compilation of material sent by many people to the birding-aus mailing list. It has not been checked for accuracy nor its content verified in any way. If you wish to get material removed from the archive or have other queries about the archive e-mail Andrew Taylor at this address: andrewt@cse.unsw.EDU.AU