I am calling a method using SOAPclient and the method (remote external SOAP web service) is returning me a 19 digit number. I have no control over what is being returned. When i print the value of this number only the first 16 digits are accurate. I have tried type casting, GMP etc. But looks like the full 19 digits is already lost when php assigns the value to the variable based on the result from the web service call. So there is no way to retrieve the value.
$client = new SoapClient($sccSystemWSDL);
try{
$sessionID = $client->logonUser($adminUser,$passWord);
}
On a 64 bit machine I did not have this issue. But now I have to run this on a 32 bit machine and no luck till now.
PHP Integers An integer data type is a non-decimal number between -2147483648 and 2147483647 in 32 bit systems, and between -9223372036854775808 and 9223372036854775807 in 64 bit systems. A value greater (or lower) than this, will be stored as float, because it exceeds the limit of an integer.
$numlength = (int)(log($num+1, 10)+1); Or for a math solution that counts the digits in positive OR negative numbers: $numlength = ($num>=0) ? (int)(log($num+1, 10)+1) : (int)(log(1-$num, 10)+1); But the strlen solution is just about as fast in PHP.
echo (int) ( (0.1+0.7) * 10 ); // echoes 7!
Use BCMath it allows the numbers to be processed as strings instead of integers so does not have size limit. Also you should increase the precision directive to a larger number say 20 or so.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With