Skip to content

Possible bug in System.Numerics BigInteger bitwise AND operation & in dotnet 9 #1458

@Hecate2

Description

@Hecate2
System.Numerics.BigInteger.Parse("-9223372036854775808") & System.Numerics.BigInteger.Parse("-9223372036854775809")

This works in dotnet 8.0.204, with a result -18446744073709551616. But in dotnet 9.0.100 it throws an exception Index was outside the bounds of the array, because System.Numerics.BigInteger.Parse("-9223372036854775808").GetBitLength() == 63, and System.Numerics.BigInteger.Parse("-9223372036854775809").GetBitLength() == 64.
(Note that -9223372036854775808 == -2^63)
I am not really sure whether this is a bug or a feature.

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