Rounding Mechanism to nearest 0.05

后端 未结 10 2021
离开以前
离开以前 2021-01-05 00:15

I would like to solve rounding mechanism by using php4,5.2 and below (not 5.3) Currently I am doing 0.05 rounding, something like this page:

http://www.bnm.gov.my/in

10条回答
  •  醉酒成梦
    2021-01-05 00:25

    Thank you @mauris for the solution to solve my problem on Malaysia GST rounding mechanism. It also works in SQL.

    DECLARE @tempTable AS TABLE(Number Decimal(20,4));

    INSERT INTO @tempTable VALUES (89.90),(89.91),(89.92),(89.93),(89.94),(89.95),(89.96),(89.97),(89.98),(89.99)

    SELECT Number, round(Number * 2, 1) / 2 AS 'Rounded' FROM @tempTable

提交回复
热议问题