SPUG: The bit pattern of a number (was sum-of-squares)
Ben Reser
ben at reser.org
Sun Oct 5 11:53:22 CDT 2003
On Sun, Oct 05, 2003 at 09:03:56AM -0700, Mathew D. Watson wrote:
> I would like to determine the bit pattern of a Perl floating point number.
> In C I would do something like:
> 1. start by assigning the address of a double to a pointer-to-char;
> 2. then I'd look at the char value (i.e. determine its bit pattern);
> 3. increment the char pointer;
> 4. repeat steps 2 & 3 until I've reached the end of the double.
>
> How do I do this in Perl? Maybe this is really simple, but I'm stumped.
I don't think you can. You can use pack but that won't really give you
a reliable representation of how perl is storing it internally.
Data::Dumper might be useful but it won't produce the data as binary
output.
Other than that I don't really have any suggestions, sorry.
--
Ben Reser <ben at reser.org>
http://ben.reser.org
"Conscience is the inner voice which warns us somebody may be looking."
- H.L. Mencken
More information about the spug-list
mailing list