perl> print unpack( 'N', chr(255).chr(255).chr(255).chr(255) ) 4294967295
The only caveat to this (or blakm's solution above) is that if the data is sourced from a system other than your own, the byte-order my be different (big-endian .v. little-endian ot vice versa) in which case you would need to use an unpack template of 'V'. The difference is demonstrated by
If the source is a foriegn system, and you are unsure of the byte ordering, you'll need a sample known value and try both to make your determination of which of 'N' or 'V' to use.perl> print unpack( 'N', chr(255).chr(127).chr(64).chr(32) ) 4286529568 perl> print unpack( 'V', chr(255).chr(127).chr(64).chr(32) ) 541097983
In reply to Re: How do I convert a 32 bit unsigned integer to it's decimal value.
by BrowserUk
in thread How do I convert a 32 bit unsigned integer to its decimal value?
by notfred
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |