Skip to content

Issue of casting f32 to e4m3mxfp #342

@wonjeon

Description

@wonjeon

Hello.
I have the following example to test casting of float number to fp8_e4m3 number:

>>> from bitstring import Bits
>>> f32 = 232.03683398099045
>>> f8 = Bits(e4m3mxfp=f32).e4m3mxfp
>>> f8
224.0
>>> abs(f32-240)
7.963166019009549
>>> abs(f32-224)
8.036833980990451

Why f8 is 224, not 240? The distance from f8 to 240 looks shorter than that to 224. Am I missing anything?

Metadata

Metadata

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions