Bitfield structs and suggestion

Don Clugston dac at nospam.com.au
Wed Mar 22 00:21:38 PST 2006


Miles wrote:
> Don Clugston wrote:
>> Maybe only the mantissa and exponent are required, the position of the
>> negative bit is fixed in the exponent, isn't it?
>> (provided that mantissa is an integral type).
> 
> I don't think so. The negative bit is not part of the exponent, it is
> really a separate field. Perhaps you are thinking about the signalling
> NaN indicator, that is the highest bit of the mantissa.

Well, the sign bit is always adjacent to the highest bit of the 
exponent. I was thinking that the exponent and sign bit could be 
combined to make a standard-sized D type -- but this only works for 80 
bit reals, not float, double, or quadruple.

> But sure would be appropriate, with a little overhead, to have better
> cooked .exponent and .mantissa properties. Only that the user wouldn't
> be able to detect a negative zero.
> 
>> Immediate interesting application: efficiently converting random
>> integers into a random real in the range 0..1, just by storing the int
>> into the mantissa of a real.
> 
> Sure!
> 
> Too bad Walter didn't seem to notice my previous post.

It's not a priority, it's something that could be added later without 
breaking anything -- just syntactic sugar, really. We can try again 
later <g>.



More information about the Digitalmars-d mailing list