Skip to content

N.pow(M) returns zero, does not overflow for unsigned N and both N and M even (sometimes) #34913

Closed
@cjsut

Description

@cjsut

Today I learned that eight to the power of eight is zero. Who'da thunk?

Incorrect:
2u8.pow(500) ➡️ 0
8u8.pow(8) ➡️ 0
4u32.pow(1000) ➡️ 0

Correct:
8u8.pow(7) ➡️ overflow ✅
8i8.pow(8) ➡️ overflow ✅
2u8.pow(9) ➡️ overflow ✅

Oddly enough, this one breaks the pattern:
2u8.pow(10) ➡️ overflow ✅

Haven't bothered with further cases; at this point it's probably best to just look at the implementation and see what's going on.

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