in reply to Hexadecimal to binary
If you want to actually do something with the converted binary number, and can live with the precision loss, then this should work on any version of Perl.
It just breaks the 128-bit hex into 4 x 32-bit lumps, converts them to numbers and multiplies them out:
$h = 'F23CC481AAE190180000000014000008';; $n = 0.0; ( $n *= 2**32 ) += unpack 'N', pack 'H*', $_ for unpack '(A8)*', $h;; print $n;; 3.21988698417062e+038 printf "%.f\n", $n;; 321988698417062150000000000000000000000
Which compared to the full precision value: 321988698417062151410473125841815470088, represents an inaccuracy of 0.00000000000000043805% Very few applications need more.
To put that into perspective, it represents just 19 seconds on the age of the universe.
|
|---|