Skip to content

The Base functions mod(::Unsigned, ::Signed) and mod(::Signed, ::Unsigned) are broken #57851

Closed
@KlausC

Description

@KlausC

In the recent (and probably earlier) version of Julia we obtain the following results, the second of which is wrong.

julia> VERSION
v"1.11.4"

julia> mod(UInt16(15000), Int16(17767))
15000

julia> mod(UInt16(15000), Int16(17768))
-15000

julia> a = Int16(6000); b = UInt16(65000)
0xfde8

julia> mod(a, b)
0x1558

julia> Int(ans)
5464

That is probably unintended result of overflows in base/int.jl:mod

Metadata

Metadata

Assignees

No one assigned

    Labels

    correctness bug ⚠Bugs that are likely to lead to incorrect results in user code without throwingmathsMathematical functions

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions