在 F# 中,如果我想使用十六进制表示法来声明双精度浮点数文本,使用文本值为 0.0 LF
后缀,我可以执行以下操作:
let zeroFloat = 0x0000_0000_0000_0000LF // returns 0.0 as float
现在,如果我想要 0.5 的浮点文字值,我可以执行以下操作:
let floatOneHalf = 0.5
let floatOneHalfScientific = 5.0e-1
但是得到 0.5 的十六进制表示法是什么?
let floatOneHalfHex = 0x????_????_????_????LF // should return 0.5
let x = 0x3fe0_0000_0000_0000LF
应该这样做。
有关详细信息,请参阅 https://gregstoll.dyndns.org/~gregstoll/floattohex/。