16bit half floating point type as defined in IEEE-754r in D?
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Tue Nov 24 08:36:28 PST 2009
s_lange wrote:
> A 16 bit precision floating point type has been defined by the IEEE in
> the revision of the 754 floating point standard and declared as
> optional. These small data types are heavily used in all kinds of
> graphics rendering software. The most prominent example beeing the gl
> libraries of the OpenGL specs.
>
> Are there any plans to support such a data type in future versions of D?
>
> regards Lange
D can store custom floating point types, see
http://www.digitalmars.com/d/2.0/phobos/std_numeric.html
where there's actually an example that creates the IEEE 16-bit float you
mention:
// Define a 16-bit floating point type
alias CustomFloat!(1, 5, 10) HalfFloat;
auto x = HalfFloat(0.125);
assert(halfFloat.get!float == 0.125);
But watch for:
http://d.puremagic.com/issues/show_bug.cgi?id=3520
which hasn't been fixed yet. Or please fix it :o).
Andrei
More information about the Digitalmars-d
mailing list