Simple math with decimals in PHP

后端 未结 4 1108
抹茶落季
抹茶落季 2021-01-22 05:11

This is killing me! I\'ve never had so much trouble and I can\'t figure out what I\'m doing wrong here.

If I have a number, say 2.32, and I want to do math with it it wo

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-22 05:44

    Besides using floats as Tim said, also make sure to use the BC Math functions when performing arithmetic operation on floating point numbers. Specifically bcmul():

    $income100 = bcmul($income, 100);

提交回复
热议问题