Web lists-archives.com

[PHP] How to gmp_import or gmp_export a negative value?




Greetings, All.

I'm working with some big numbers my platform can't handle, and I need a way
to store and retrieve them reliably.
But much to my dismay, I've found that GMP is unable to handle negative
numbers import/export.
This can be demonstrated with a very short script:

https://3v4l.org/gOENE
<?php

$x = "\xff";
$s = gmp_export(unpack('c', $x)[1], 1);
printf("In: %d, Out: %d\n", ord($x), ord($s));

If this an intended behavior? Or am I missing some flag to make it work the
desired way?


-- 
Sincerely Yours, Andrey Repin <anrdaemon@xxxxxxxxxxx>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php