www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Problem¦with¦COS

reply Luis¦Rodrigues <Luis¦Rodrigues_member pathlink.com> writes:
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
next sibling parent J Anderson <REMOVEanderson badmama.com.au> writes:
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
prev sibling parent hellcatv hotmail.com writes:
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_
May 08 2004