Reputation: 1863
I have this problem:
// 7788778877887786660462040644602088666448 (10) = 9mwjmtyko1mpect1brz2exoncc (36)
$a = 7788778877887786660462040644602088666450 - 2;
echo $a."<br>"; // prints 7.7887788778878E+39
$b = "9mwjmtyko1mpect1brz2exoncc";
echo base_convert($b, 36, 10)."<br>"; //prints 7788778877887786660462040644602088666448
I know why $a
was printed to 7.7887788778878E+39
, it's because the value of $a
is over the integer limit.
But, why it is not being 7.7887788778878E+39
when I convert 9mwjmtyko1mpect1brz2exoncc
to decimal? It just prints the exact value (7788778877887786660462040644602088666448
)
How can I print $a
to the exact value (ignoring error)?
Is 7788778877887786660462040644602088666448
another data type that is bigger than long/unsigned-long?
Upvotes: 1
Views: 147
Reputation: 163437
Looking at some of the answers on this page: How to keep long int during PHP string conversion? I don't think you can do that because the large values are being stored as a float.
Suggestions are to use a library like BC Math and GMP, but I think that those are not enabled in PHP by default.
Upvotes: 1