[ Date Index ][
Thread Index ]
[ <= Previous by date /
thread ]
[ Next by date /
thread => ]
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
mike wrote: | | $binstr = '10011000111111001011100';
I think we need to know the number representation as the above is; ~ 4C7E5C not 844C7E5C
$binstr = 0b10011000111111001011100; print $binstr/(2**18),"\n";
I think the mistake is to start with 32 in dblnum, and then add your number to it. But I may have misunderstood the number representation.
| What I need to do is take 51.1234 and turn in back into a binary string.
$decim = (2**18)*19.1234 ; $hex = sprintf "0x%X",$decim ; print $hex,"\n";
Maths is suppose to be my strong point, but after 3 years of it at university I did better on the verbal reasoning tests on my civil service recruitment exam(?!) so there are no guarantees I'm not blundering badly here.
Anyway be careful, Perl does double precision maths by default so multiply or divide by 2**18 isn't THAT risky for every day numbers, but I agree with Neil use the proper routines, or use one of the maths shells (yacas is cool) to avoid tripping over representation issues. -----BEGIN PGP SIGNATURE----- Comment: Using GnuPG with Debian - http://enigmail.mozdev.org
iD8DBQFBU0evGFXfHI9FVgYRAurMAJ4igOjtumu2bdKxyWrw0kNQ/3dOuQCfdzjL fdQ+B0oRWpjyU083ziFxi2A= =Sc99 -----END PGP SIGNATURE-----
-- The Mailing List for the Devon & Cornwall LUG Mail majordomo@xxxxxxxxxxxx with "unsubscribe list" in the message body to unsubscribe.