PHP rounding problem (5.2.3)?

前端 未结 3 1436
时光取名叫无心
时光取名叫无心 2021-01-12 11:10

I\'m wondering if I found an issue with the rounding in PHP, specifically 5.2.3 (I\'m not sure about other versions at the moment):

$t = 0;

$taxAmount = (5.         


        
3条回答
  •  -上瘾入骨i
    2021-01-12 12:03

    Python says:

    >>> repr(5./100*0.7)
    '0.034999999999999996'
    

    This is due to IEEE754 accuracy limitations. Use a fixed-point type if you need exact accuracy.

提交回复
热议问题