Skip to content

factorial and Int64 #6579

@my-little-repository

Description

@my-little-repository

Factorial returns a wrong result for all Int64 integers bigger than 20, due to overflow.

 julia> factorial(21)
-4249290049419214848

I suggest converting the argument to BigInt if it is an Int64 bigger than 20, or at least
returning a warning that the result is wrong.

It seems that factorial convert other number types like Int32 or Int8 to Int64 if there is an overflow for these types, so that handling Int64 should be sufficient to handle all non-Bool Integer types.

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedIndicates that a maintainer wants help on an issue or pull request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions