0

when working with very big numbers, php convert it to scientific notation, and I exactly need the number not the scientific notation, what should I do? also strval doesn't work .

$x=15698545987213548634564235131; 

when echo, the output is 1.5698545987214E+28

but I need the output to be exactly:

15698545987213548634564235131
ADyson
  • 57,178
  • 14
  • 51
  • 63
  • 3
    Does this answer your question? [Echo a very large number](https://stackoverflow.com/questions/12609093/echo-a-very-large-number). Did you do any basic research before rushing to ask a question? – ADyson Oct 18 '21 at 15:09
  • Thanks for the edit but...did you look at the link I provided before that? It already tells you what to do. And if you'd googled your question to begin with you should have found it already. It's not clear why you're still stuck – ADyson Oct 18 '21 at 15:28
  • @ADyson I searched the page you mentioned but non worked for this particular number, it changes the output number,I appreciate if you could help – bagher abdollahi Oct 18 '21 at 16:24
  • So then please edit the question to show us what you tried exactly, and what exactly the output was. Then it demonstrates that your problem may be different than the one mentioned in the link. That way we know where to start from with helping. – ADyson Oct 18 '21 at 16:26
  • No, I meant show how you tried to use the solution shown in the link I provided, and what went wrong with it – ADyson Oct 18 '21 at 16:43
  • The accepted answer (indeed the entire technique) in the dup won't work because OPs integer is too big (94 bits). The other answers may or may not work. – President James K. Polk Oct 18 '21 at 18:35
  • Ok so it looks like maybe this number will overflow the bounds of a PHP int, and be interpreted as a float - see https://www.php.net/manual/en/language.types.integer.php and that's why the output changes. (But it still would have been better if you actually demonstrated this more clearly in your question and ruled out other existing solutions explicitly.) It's a 94-bit number as the above notes, but PHP can only deal with 64-bit integers or below. – ADyson Oct 18 '21 at 20:39
  • https://stackoverflow.com/questions/2711364/does-php-have-a-data-type-bigger-than-int may assist you instead – ADyson Oct 18 '21 at 20:40
  • See also https://stackoverflow.com/questions/670662/whats-the-maximum-value-for-an-int-in-php – ADyson Oct 18 '21 at 20:40

0 Answers0