Skip to content

->signum() bug #9

@FoxKeys

Description

@FoxKeys

Looks like i have found a bug. signum() for zero expected to be a zero. But, it is returns 1.

decimal support | enabled
decimal version | 1.1.0
libmpdec version | 2.4.2

Test code:

    $a = new Decimal(0);
    print_r($a);
    echo 'isZero? ', var_export($a->isZero(), true), "\n";
    echo 'signum: ', $a->signum(), "\n";
    $a = new Decimal(1);
    print_r($a);
    echo 'isZero? ', var_export($a->isZero(), true), "\n";
    echo 'signum: ', $a->signum(), "\n";
    $a = new Decimal(-1);
    print_r($a);
    echo 'isZero? ', var_export($a->isZero(), true), "\n";
    echo 'signum: ', $a->signum(), "\n";

Output:

Decimal\Decimal Object
(
    [value] => 0
    [precision] => 28
)
isZero? true
signum: 1
Decimal\Decimal Object
(
    [value] => 1
    [precision] => 28
)
isZero? false
signum: 1
Decimal\Decimal Object
(
    [value] => -1
    [precision] => 28
)
isZero? false
signum: -1

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