Skip to content

Cannot handle Float correctly on Windows #160

Open

Description

@SaiCateDoan

lambda obj, ctx: numpy.frombuffer(obj.rjust(16, b"\x00"), dtype=numpy.longdouble),

Two reasons:

  1. numpy.longdouble is alias of float64 on Windows, but not float96 or float128, so I run it on WSL
  2. numpy.frombuffer returns ndarray, but not a particular number, so I just patched it

I think this might be work, but I only test the function of dump file, so you know...

Test file: 0000001C.zip

Activity

  1. pmrowla commented on Jun 10, 2025

    @pmrowla
    Owner

    Thanks for the sample LSB. I need to revisit the float/double handling since the 80-bit extended precision doubles are also unavailable on ARM64 (apple silicon macs). This probably means handling the 80-bit serialization ourselves and accepting some loss of precision, but I don't have time to work on this at the moment.

    In WSL on an x86 CPU, your patch should be fine as a temporary fix. If you also need writing/editing the LSB, it looks like there's another bug where tobytes() should be called using ndarray. You may also want to explicitly change numpy.longdouble to numpy.float96, although I think it should work either way on WSL or native x86 Linux.

    So an updated patch to handle both dump + edit would look something like:

    "Float": construct.ExprAdapter(
        construct.Bytes(10),
        lambda obj, ctx: numpy.frombuffer(obj.rjust(16, b"\x00"), dtype=numpy.float96, count=1)[0],
        lambda obj, ctx: numpy.array([obj], dtype=numpy.float96).tobytes()[-10:],
    ),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions