Skip to content

_finalize_numeric in steps/dtypes.py can silently overflow on large integer-like floats #34

Description

@JohnnyWilson16

In steps/dtypes.py:

_INT64_SAFE = float(2**63 - 1024)

Values between 9223372036854774784 and 2**63 - 1 = 9223372036854775807 pass the guard but fail .astype("int64") on some numpy versions because they exceed the int64 max. The guard is off by ~1023 values.
Additionally, negative values are checked via .abs().max(), but int64 is asymmetric: it can hold -2**63 but not +2**63. A value of exactly -2**63 has abs() = 2**63 which is > _INT64_SAFE, so it's correctly rejected. But a value of -9223372036854775000 has abs() < _INT64_SAFE and would pass.
Fix: Use _INT64_SAFE = float(2**63 - 1) and change the comparison to <=.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions