"double floor(double)"
Dear Sirs.
I have observed that under certain circumstances a "double" beeing casted
to a "long int" and then back to "double" produces fancy results. A small
test-scenario can be found below. It runs fine on i386 architecture.
I have no specific alpha experience. I will be happy for any comments on the
following described below.
Thank you for your patience,
Thomas Moor.
******* c-source code, test.c:
#include <math.h>
#include <stdio.h>
int main(int argc,char** argv){
long i;
double a;
i=(long)(floor(.3)); /* i should become 0*/
a=(double)i; /* a should become 0.0 */
printf("i=%d; a=%f;\n",i,a); /* prints out funny number for a */
exit(0);
}
******* compiled by:
$ gcc --ansi test.c -lm
******* executed:
$ ./a.out
******** observed output:
i=0; a=36028797018963968.000000;
******** version of gcc used:
$ gcc -v
Reading specs from /usr/lib/gcc-lib/alpha-linux/2.95.2/specs
gcc version 2.95.2 20000313 (Debian GNU/Linux)
******** librarays used when a.out was executed:
$ ldd a.out
libm.so.6.1 => /lib/libm.so.6.1 (0x000002000011e000)
libc.so.6.1 => /lib/libc.so.6.1 (0x0000020000258000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0000020000000000)
--
Thomas Moor
Research School of Information Sciences and Engineering
Australian National University
Canberra ACT 0200 AUSTRALIA
email: thomas.moor@anu.edu.au
phone: +61 2 6279 8680
Reply to: