Answer the question
In order to leave comments, you need to log in
Mysql - store a large number (10^25) and then use it for calculations?
there is a need to store large numbers in php. in mysql I wrote to varchar(200) but it comes out 8.829090563937061e20 . how to do accurate and normal data saving. ps in some places, the processing is done in mysql itself (that is, ... set `data`=`data`/112, well, something like that). what am i doing wrong?
Answer the question
In order to leave comments, you need to log in
the problem starts back in php, so
in php, numbers are converted to type float and all precision is lost.
for precise work with large numbers, the bc module is used
example for addition php.net/manual/ru/function.bcadd.php
that is, the numbers must be strictly strings
in mysql, you correctly make varchar for storage, but you cannot work with such numbers there.
based on the task, you need to think about what you can give up
either get it in php and divide php.net/manual/ru/function.bcdiv.php and then write it down again,
or if it is necessary for sorting, for example, then add a double field and duplicate it, the accuracy will be less, but it should be enough for sorting.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question