Skip to content

Instantly share code, notes, and snippets.

@agrif
Created April 21, 2011 15:52
Show Gist options
  • Save agrif/934818 to your computer and use it in GitHub Desktop.
Save agrif/934818 to your computer and use it in GitHub Desktop.
hacky php unsigned long to float
$n = unpack("N", ...);
$res = 0.0;
for ($bit = 0; $bit < 32; $bit++) {
if ($n & (1 << $bit)) {
$res += pow(2, $bit);
}
}
echo $res;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment