How to gmp_import or gmp_export a negative value?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux