Skip to content

[BUG] int(QuadPrecision('inf'|'nan'|'1e30')) silently returns INT64_MAX #97

@SwayamInSync

Description

@SwayamInSync
int(QuadPrecision('inf'))   # = 9223372036854775807   (should raise OverflowError)
int(QuadPrecision('nan'))   # = 9223372036854775807   (should raise ValueError)
int(QuadPrecision('1e30'))  # = 9223372036854775807   (should return ~1e30)

Root Cause is the following piece of code inside src/csrc/scalar_ops.cpp

return PyLong_FromLongLong(Sleef_cast_to_int64q1(self->value.sleef_value));

We should instead take the quad_to_pylong path, already present for as_integer_ratio and raise on NaN/Inf.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions