what's the scope?
I have some brain-teasing functions i've been working on, but they are far
from bulletproof, but here is an example
function float_int($significand) {
$sign = ($significand<0) ? true : false;
$significand = abs($significand);
$drep = (decbin( (int) $significand));
$frep = "";
for($i = 0; $i <= 22; $i++) {
$significand = ($significand - (int) $significand)*2;
if($significand == 0) break;
$frep .= ($significand >= 1) ? "1" : "0";
}
$significand = preg_replace("/^0*1/", "",
$drep.$frep);
$significand = (strlen($significand) < 23) ? str_pad($significand, 23,
"0") : substr($significand, 0,
23);
if($drep) {
$exponent = decbin(126+strlen($drep));
} else {
$tmp = preg_split('/1/', $drep.$frep, 2, PREG_SPLIT_OFFSET_CAPTURE);
$exponent = decbin((-$tmp[1][1])+127);
}
$f = bindec($exponent.$significand);
return (!$sign) ? $f : $f^0xFFFFFFFF;
}
I guess the function name and variable names will offer some assistance in
determining what this does, but i think its an interesting brain-bender, not
very useful, because its pretty slow, but still :)
-- Alex --
--
The trouble with programmers is that you can never tell what a programmer is
doing until it’s too late. ~Seymour Cray
On Fri, May 20, 2011 at 12:49 PM, Steve Staples <[email protected]> wrote:
> Just wondering if anyone has done anything for this? I personally
> haven't had any "ideas" come to mind yet...
>
> Looking forward to seeing them!!! (once they come)
>
>
> Steve
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>