<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 15 July 2013 16:54, H. S. Teoh <span dir="ltr"><<a href="mailto:hsteoh@quickfur.ath.cx" target="_blank">hsteoh@quickfur.ath.cx</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Tue, Jul 16, 2013 at 12:04:08AM +1000, Daniel Murphy wrote:<br>
> I would prefer to see (as either builtins or properties) a way to<br>
> get/set the exponent/mantissa/sign of a float.<br>
><br>
> eg<br>
> float x;<br>
> x.sign = 1;<br>
> assert(x.exp == 123);<br>
><br>
> Easily ctfeable, no need for casting, no endianness problems.<br>
</div>[...]<br>
<br>
+1. IMO this is the right way to handle floating-point attributes.<br>
Direct knowledge about the binary representation should be restricted to<br>
the compiler as much as possible. Plus, having these attributes could<br>
potentially be useful in other contexts than std.math.<br></blockquote><div><br></div><div>No. You shouldn't be doing these kind of operations in normal code, you should be using normal arithmetic. If you need to know the exponent, you should use library functions like frexp().<br>
</div><div>You shouldn't be poking in the internals of a float unless you know the bit pattern exactly, and you need the extra speed.<br></div><div>This issue only applies to 80-bit reals on x86, this is really a very special case. Floats and doubles already allow the necessary casts.<br>
</div><div><br></div><div><br></div><div><br></div><br><div><br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class="HOEnZb"><font color="#888888"><br>
<br>
T<br>
<br>
--<br>
The best way to destroy a cause is to defend it poorly.<br>
</font></span><div class="HOEnZb"><div class="h5">_______________________________________________<br>
dmd-internals mailing list<br>
<a href="mailto:dmd-internals@puremagic.com">dmd-internals@puremagic.com</a><br>
<a href="http://lists.puremagic.com/mailman/listinfo/dmd-internals" target="_blank">http://lists.puremagic.com/mailman/listinfo/dmd-internals</a><br>
</div></div></blockquote></div><br></div></div>