Skip to content

rem(::BigFloat, ::Type{<:Normed}) may return an incorrect value #211

Closed
@kimikage

Description

@kimikage

This isn't a fatal issue in practice, but I ran into it in testing multiplication code.

julia> BigFloat(0x0_01234567_89abcdef) % N63f1 |> reinterpret
0x0123456789abcdef

julia> BigFloat(0x1_01234567_89abcdef) % N63f1 |> reinterpret
0xffffffffffffffff

The cause is the unsafe_trunc.

julia> r = 0x1_01234567_89abcdef;

julia> bf = BigFloat(r)
1.8528729602926038511e+19

julia> bi = BigInt(bf)
18528729602926038511

julia> unsafe_trunc(UInt64, bf)
0xffffffffffffffff

julia> unsafe_trunc(UInt64, bi)
0x0123456789abcdef

Perhaps it would be better to convert via BigInt.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions