Coder-Spirit / php-bignumbers

A robust library to handle immutable big numbers inside PHP applications
MIT License
131 stars 29 forks source link

Fix for float precision errors using number_format() #37 #40

Closed shabbyrobe closed 9 years ago

shabbyrobe commented 9 years ago

Funnily enough, I just ran into this one myself today. I've got a potential fix that covers some of the crazier cases I came across better than my suggestion on the issue page.

castarco commented 9 years ago

It seems ok :) , only one question before the merge: In the tests (line 55) you are using a conditional, something like

    if (PHP_INT_SIZE) {

I'm not convinced that this conditional is correct. If you want to ensure that the conditional block is only executed on 64bits platforms, then the conditional should be something like

    if (PHP_INT_SIZE > 4) {

or

    if (PHP_INT_SIZE == 8) {
shabbyrobe commented 9 years ago

Oops! Good spot, that is definitely what it is meant to do! I used a combination of both suggestions :)