John H. Robinson, IV wrote:
John H. Robinson, IV wrote:
$number =~ /^([01])([01]{11})([01]{26})([01]{26})$/;
$s=$1; $e=eval "0b$2"; $f1=eval "0b$3"; $f2=eval "0b$4";
$f=$f1 * 1<<26 + $f2;
$f=eval "1.$f";
$double=-1***$s * 2 **($e-1023) * $f;
This code snippet sucks.
I disavow any knowledge of it, as I merely found it in the gutter and
thought it looked useful.
<smirk>
And this is why I don't use Perl anymore unless it's a pure one-liner.
The whole Perl community is all about "what works *now*". If that means
grabbing an opaque code snippet that nobody will be able to understand
later (or even right now), so be it.
Yes, I can read that snippet. But only because I understand the
significance of some of the constants from designing floating point
hardware. And, at least nothing in there appears to be relying on odd
scalar/array context issues for meaning.
And, that snippet *doesn't* suck if you are stuck on hardware that is
not IEEE 754 compliant. So, my guess is that snippet is pretty ancient.
-a
--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg