Voting

: min(one, eight)?
(Example: nine)

The Note You're Voting On

sneskid at hotmail dot com
13 years ago
If you want to create or parse signed Hex values:

<?php
// $d should be an int
function sdechex($d) { return ($d<0) ? ('-' . dechex(-$d)) : dechex($d); }

// $h should be a string
function shexdec($h) { return ($h[0] === '-') ? -('0x' . substr($h,1) + 0) : ('0x' . $h + 0); }

// test

$v = sdechex(-123); // string(3) "-7b"
$i = shexdec($v); // int(-123)
var_dump($v, $i);
?>

Also note that ('0x' . $str + 0) is faster than hexdec()

<< Back to user notes page

To Top