[Issue 5866] New: std.math.sin(float), std.math.cos(float) to return float

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Apr 20 04:11:56 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=5866

           Summary: std.math.sin(float), std.math.cos(float) to return
                    float
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at eml.cc 2011-04-20 04:08:20 PDT ---
Currently (DMD 2.052) std.math doesn't seem to use the cosf, sinf C functions,
but it seems to use sqrtf (or something similar):


import std.math: sqrt, sin, cos;
import core.stdc.math: sqrtf, sinf, cosf;
void main() {
     float x = 1.0f;
     // C functions
     static assert(is(typeof( sqrtf(x) ) == float)); // OK
     static assert(is(typeof( sinf(x)  ) == float)); // OK
     static assert(is(typeof( cosf(x)  ) == float)); // OK
     // D functions
     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'd like std.math.sin/cos to return a float value when the input argument is a
float.

This is useful if you want to perform operations on floats and keep
intermediate expressions (that call sin/cos) as floats:

enum float PI_FLOAT = 3.14159265358979323846264f; // not present in std.math
float x = 0.3f;
float y = 2.0f * PI_FLOAT * sin(x); // contains no double->float conversions

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list