Replacing std.math raw pointer arithmetic with a union type

tsbockman via Digitalmars-d digitalmars-d at puremagic.com
Tue May 16 20:02:02 PDT 2017


std.math contains a lot of raw pointer arithmetic for accessing 
the various bit fields of floating-point values (see 
https://en.wikipedia.org/wiki/IEEE_754-1985). Much of this code 
has several nearly-identical copies, manually specialized for 
each supported floating-point format.

Such code is verbose, hard to read, and, judging by the bugs and 
missing specializations I've found, hard to write correctly. It 
is also not compatible with CTFE.

A while ago I created Phobos #4336 
(https://github.com/dlang/phobos/pull/4336), which begins the 
process of replacing all the pointer arithmetic in std.math, and 
the supporting floatTraits template, using a fast union type: 
RealRep.

Ian Buclaw recently approved my work, but I believe that a pull 
request of this size and importance should be review by at least 
one other qualified person.

Would any of our other floating-point experts be willing to take 
a look?


More information about the Digitalmars-d mailing list