PHP 8.5.0 Beta 1 available for testing

Voting

: one plus four?
(Example: nine)

The Note You're Voting On

artefact2 at gmail dot com
15 years ago
Here are some useful functions to convert large hex numbers from and to large decimal ones :

<?php
public static function bchexdec($hex) {
if(
strlen($hex) == 1) {
return
hexdec($hex);
} else {
$remain = substr($hex, 0, -1);
$last = substr($hex, -1);
return
bcadd(bcmul(16, bchexdec($remain)), hexdec($last));
}
}

public static function
bcdechex($dec) {
$last = bcmod($dec, 16);
$remain = bcdiv(bcsub($dec, $last), 16);

if(
$remain == 0) {
return
dechex($last);
} else {
return
bcdechex($remain).dechex($last);
}
}

<< Back to user notes page

To Top