Large hex values with PHP hexdec

前端 未结 7 1323
清歌不尽
清歌不尽 2020-12-03 08:23

I have some large HEX values that I want to display as regular numbers, I was using hexdec() to convert to float, and I found a function on PHP.net to convert that to decima

7条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-03 09:02

    $num = gmp_init( '0xD5CE3E462533364B' ); // way to input a number in gmp
    echo gmp_strval($num, 10); // display value in decimal
    

    That's the module to use. Convert it to a function and then use on your numbers.

    Note: provide these hex numbers as strings so:

    $num = "0x348726837469972346"; // set variable
    $gmpnum = gmp_init("$num"); // gmp number format
    echo gmp_strval($gmpnum, 10); // convert to decimal and print out
    

提交回复
热议问题