Thread overview
Problem¦with¦COS
May 08, 2004
Luis¦Rodrigues
May 08, 2004
J Anderson
May 08, 2004
hellcatv
May 08, 2004
I¦have¦this¦code:
printf("%f\n",¦cos(0.883573));
and¦it¦prints¦-0.0000,¦why?

I've¦imported¦std.math

Thanks.

_LR_
May 08, 2004
Luis¦Rodrigues wrote:

>I¦have¦this¦code:
>printf("%f\n",¦cos(0.883573));
>and¦it¦prints¦-0.0000,¦why?
>
>I've¦imported¦std.math
>
>Thanks.
>
>_LR_
>  
>
Try converting the real to a float first:

printf("%f\n", cast(float) cos(0.883573));

-- 
-Anderson: http://badmama.com.au/~anderson/
May 08, 2004
I had trouble linking when using cos in gdc
my solution was to use version and  cosl
cos worked fine for me in dmd.exe

import std.c.math;
import std.math;
version(Windows) {
return std.math.cos(x);
}else {
return cast(VALUE)std.c.math.cosl(cast(real)x);
}

In article <c7j5gn$1qka$1@digitaldaemon.com>, Luis¦Rodrigues says...
>
>I¦have¦this¦code:
>printf("%f\n",¦cos(0.883573));
>and¦it¦prints¦-0.0000,¦why?
>
>I've¦imported¦std.math
>
>Thanks.
>
>_LR_