www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - sin(float), cos(float)

reply bearophile <bearophileHUGS lycos.com> writes:
In the C standard library there are the sqrtf, cosf, sinf functions, that
return a 32 bit float. In D std.math.sqrt returns a float if the input argument
is float, but sin and cos return double even if their argument is float:

import std.math: sqrt, sin, cos;
void main() {
    float x = 1.0f;
    static assert(is(typeof(  sqrt(x)  ) == float)); // OK
    static assert(is(typeof(  sin(x)   ) == float)); // ERR
    static assert(is(typeof(  cos(x)   ) == float)); // ERR
}

I think this is not correct, and it's worth a Bugzilla entry (if not already
present). Do you agree?

Bye,
bearophile
Apr 19 2011
parent bearophile <bearophileHUGS lycos.com> writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5866
Apr 20 2011