[dmd-internals] Pure CTFE-able std.math

H. S. Teoh hsteoh at quickfur.ath.cx
Mon Jul 15 07:54:40 PDT 2013


On Tue, Jul 16, 2013 at 12:04:08AM +1000, Daniel Murphy wrote:
> I would prefer to see (as either builtins or properties) a way to
> get/set the exponent/mantissa/sign of a float.
> 
> eg
> float x;
> x.sign = 1;
> assert(x.exp == 123);
> 
> Easily ctfeable, no need for casting, no endianness problems.
[...]

+1. IMO this is the right way to handle floating-point attributes.
Direct knowledge about the binary representation should be restricted to
the compiler as much as possible. Plus, having these attributes could
potentially be useful in other contexts than std.math.


T

-- 
The best way to destroy a cause is to defend it poorly.


More information about the dmd-internals mailing list