On Wed, 19 Dec 2012 09:35:39 -0600, Andrei Alexandrescu <[email protected]> wrote:

On 12/19/12 2:30 AM, Walter Bright wrote:
https://github.com/D-Programming-Language/phobos/pull/1018/files

Shouldn't it be part of std.numeric?

Related, we should have a decision point "this must go through the review process" vs. "the pull review process is sufficient". New modules definitely must go through the review process, as should large additions to existing models.


Andrei

It _IS_ part of std.numeric! Specifically std.numeric.CustomFloat!16; To quote our own documentation:

// Define a 16-bit floating point values
CustomFloat!16 x; // Using the number of bits CustomFloat!(10, 5) y; // Using the precision and exponent width CustomFloat!(10, 5,CustomFloatFlags.ieee) z; // Using the precision, exponent width and format flags CustomFloat!(10, 5,CustomFloatFlags.ieee, 15) w; // Using the precision, exponent width, format flags and exponent offset bias

 // Use the 16-bit floats mostly like normal numbers
 w = x*y - 1;
 writeln(w);

 // Functions calls require conversion
z = sin(+x) + cos(+y); // Use uniary plus to concisely convert to a real z = sin(x.re) + cos(y.re); // Or use the .re property to convert to a real
 z = sin(x.get!float)  + cos(y.get!float);            // Or use get!T
z = sin(cast(float)x) + cos(cast(float)y); // Or use cast(T) to explicitly convert

-------------------
The only item missing from std.numeric.CustomFloat is to add an alias this line so that implicit conversion is supported. Oh, and documentation of the standard float properties, such as infinity/min/min/etc, which exist in the code, but are template methods and so don't appear in the ddoc.

Reply via email to