Round number to specified number of digits

后端 未结 3 1553
甜味超标
甜味超标 2021-02-07 01:57

Is there a simple function to round a Double or Float to a specified number of digits? I\'ve searched here and on Hoogle (for (Fractional a) =>

3条回答
  •  梦谈多话
    2021-02-07 02:45

    λ: ((/100) $ fromIntegral $ round (0.006 * 100)) == 0.006
    λ: False
    
    λ: ((/100) $ fromIntegral $ round (0.06 * 100)) == 0.06
    λ: True
    

提交回复
热议问题