Recently encountered a strange problem, the mall through the payment of orders often less than a penny, after the troubleshooting is a problem caused by the accuracy of PHP floating point arithmetic
By the PHP floating-point arithmetic precision caused by, bird Brother's Bolg have detailed description. Http://www.laruence.com/2013/03/26/2884.html,
Decimal in binary notation, 0.58 for binary, is an infinitely long value
The binary representation of 0.58 is basically (52 bits) is: 0010100011110101110000101000111101011100001010001111 0.57 of the binary representation basically (52 bits) is: 0010001111010111000010100011110101110000101000111101
Convert to floating point number (64-bit double precision)
0.56999999999999995 0.58, 0.57999999999999996, 0.57
0.58*100 = 57.999999999 (int) (
Workaround:
(int) ((0.58*1000)/10) = 58
PHP floating-point arithmetic accuracy caused by the order amount of payment often less than 1 points of the problem