You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In order to reason about Python's ndarray type stored on disk, we need to be able to read a file of bytes and interpret it as a Lean Array of Float. Since the float bits are represented in IEEE-754 binary format, we need a way to go from UInt64 or ByteArray to Float and vice versa. There seems to be no way to accomplish this today.
For example, the following code should
#eval
let f := 1.67
let n : UInt64 := 0x3FFAB851EB851EB8 -- Closest double to 1.67 in hex
let f' : Float := Float.ofUInt64Bytes n
let n' := f.toUInt64Bytes
f == f' && n == n'
This PR adds raw transmutation of floating-point numbers to and from
`UInt64`. Floats and UInts share the same endianness across all
supported platforms. The IEEE 754 standard precisely specifies the bit
layout of floats. Note that `Float.toBits` is distinct from
`Float.toUInt64`, which attempts to preserve the numeric value rather
than the bitwise value.
closes#6071
This PR adds raw transmutation of floating-point numbers to and from
`UInt64`. Floats and UInts share the same endianness across all
supported platforms. The IEEE 754 standard precisely specifies the bit
layout of floats. Note that `Float.toBits` is distinct from
`Float.toUInt64`, which attempts to preserve the numeric value rather
than the bitwise value.
closesleanprover#6071
Proposal
In order to reason about Python's
ndarray
type stored on disk, we need to be able to read a file of bytes and interpret it as a LeanArray
ofFloat
. Since the float bits are represented in IEEE-754 binary format, we need a way to go from UInt64 or ByteArray to Float and vice versa. There seems to be no way to accomplish this today.For example, the following code should
should eval to
true
.A brief thread on Zulip where it was deemed impossible to do this today.
The text was updated successfully, but these errors were encountered: