/* $Id$ */ #include /* * Copyright (c) 2006 Chris Kuethe * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * this simple program tests to see whether your system can do proper * single and double precision floating point. This is apparently Very * Hard To Do(tm) on embedded systems, judging by the number of broken * ARM toolchains I've seen... :( * * compile with: gcc -O -o floattest floattest.c * (use whatever -O level you like) */ int main( void ); int test_single( void ); int test_double( void ); int main(){ int i; if ((i = test_single())){ printf("WARNING: Single-precision " "floating point math might be broken (test %d)\n", i); return i; } if ((i = test_double())){ printf("WARNING: Double-precision " "floating point math might be broken (test %d)\n", i); return i; } printf("floating point math appears to work\n"); return 0; } int test_single(){ static float f; static int i; /* addition test */ f = 1.0; for(i = 0; i < 10; i++) f += (1<