digitalmars.D.bugs - math
Could anyone tell me which part of my program is wrong.
I'm using version 0.98 (download from ftp.digitalmars.com/dmd.zip)
on linux (fedora core 2).
import std.math;
int main( char[][] arg )
{
double d;
d = 0.5;
printf("%f\n", sin(d));
printf("%e\n", sin(d));
return 0;
}
I got the following result. Is it OK?
-698625369815211718378554677465583019603259137860293313598822589260516170206686081027350142193452335800939574198423310222441035662104590869532633447231577762165250828259364817839638699012687998639440540605545556135551400652591406054794302384598256244586708992.000000
-6.986254e+257
Thanks,
Aug 12 2004
newbee wrote:
import std.math;
int main( char[][] arg )
{
double d;
d = 0.5;
printf("%f\n", sin(d));
printf("%e\n", sin(d));
return 0;
}
I got the following result. Is it OK?
-698625369815211718378554677465583019603259137860293313598822589260516170206686081027350142193452335800939574198423310222441035662104590869532633447231577762165250828259364817839638699012687998639440540605545556135551400652591406054794302384598256244586708992.000000
-6.986254e+257
gosh... %f and %e are for floats while sin returns a double... why are
you ppl still using printf ? replace that with writefln and get rid of
%f and \n... just writefln(sin(d)) is fine... then do writefln("%e",
sin(d)) and again there are no problems...
Aug 12 2004








h3r3tic <h3r3tic dev.null>