Skip to content

bitWidth is wrong for -(power-of-two) #115

@wadetregaskis

Description

@wadetregaskis
XCTAssertEqual(64, BigInt(Int64.min).bitWidth)

That fails, because bitWidth returns 65. It's not correctly handling the cases of 0b1 followed by some number of 0b0's, because with two's complement the magnitude of your minimum value is one higher than of your maximum value. Doing magnitude.bitWidth + 1 fails to account for this.

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