Skip to content
This repository was archived by the owner on Feb 13, 2023. It is now read-only.
This repository was archived by the owner on Feb 13, 2023. It is now read-only.

Possible bug in BcNumber #2

@jaypha

Description

@jaypha

Hello
In BcNumber::int() at line 141, is the following code

if (bccomp(strval(PHP_INT_MAX), $this->value, 0) === 1) {
throw new \DomainException('Stored BcNumber cannot be converted to signed PHP integer, exceeds PHP_INT_MAX');
}

bccomp will return 1 if the first parameter is larger that the second parameter. So in this code, an exception will be thrown if PHP_INT_MAX is greater than $value, which does not make sense.

Should it perhaps be comparing to -1?

if (bccomp(strval(PHP_INT_MAX), $this->value, 0) === -1) {

Thank you for your efforts.
Regards, Jason.

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