Eug*_*hev -2 floating-point f#
乘法
(327.59 * 100.0)
Run Code Online (Sandbox Code Playgroud)
产生的数字小于32759,为什么呢?这怎么可以避免?
使用F#Interactive的修改后的漂亮打印机,可以完全显示数字精度.
fsi.AddPrinter( fun (x:float) -> sprintf "%26.16e" x)
(327.59 * 100.0)
// val it : float = 3.2758999999999996e+004
32759.0
// val it : float = 3.2759000000000000e+004
Run Code Online (Sandbox Code Playgroud)
这就是为什么
(327.59 * 100.0) < 32759.0 = true
Run Code Online (Sandbox Code Playgroud)