aduncan@rhea.trl.oz.au (Allan Duncan) (12/12/89)
I've had one query WRT Manx modf bug, here's a sample prog : -
#include <math.h>
#include <stdio.h>
main()
{
double n ;
double a, x ;
while( 1 ) {
printf( "?> " ) ;
scanf( "%lf", &x ) ;
a = modf( x, &n ) ;
printf( "%lf -> %lf & %lf\n", x, n, a ) ;
}
}
feed it 2.1 and the answer should be 2 and 0.1 (same sign)
or -2.1 to get -2 and -0.1
If you do
cc test.c
ln test.o -lm -lc (FFP)
you will find that the fraction is always incorrectly signed.
but with IEEE ( ln test.o -lma -lc) it is correct.
As an aside, I had great trouble getting this to work until I realised
that the definition of modf args given in Harbison & Steele was wrong -
double modf(x, nptr)
double x ;
int *nptr ;
it should be double *nptr ; !
Allan Duncan ACSnet aduncan@rhea.trl.oz
ARPA aduncan%rhea.trl.oz.au@uunet.uu.net
UUCP {uunet,hplabs,ukc}!munnari!rhea.trl.oz.au!aduncan
Telecom Research Labs, PO Box 249, Clayton, Victoria, 3168, Australia.