diff --git a/php_decimal.c b/php_decimal.c index 4871780..cbcb9c3 100644 --- a/php_decimal.c +++ b/php_decimal.c @@ -2373,7 +2373,10 @@ PHP_DECIMAL_ARGINFO_END() PHP_DECIMAL_METHOD(isPositive) { PHP_DECIMAL_PARAMS_PARSE_NONE(); - RETURN_BOOL(mpd_ispositive(THIS_MPD())); + + mpd_t *mpd = THIS_MPD(); + + RETURN_BOOL(!mpd_isnan(mpd) && mpd_ispositive(mpd)); } /** @@ -2384,7 +2387,10 @@ PHP_DECIMAL_ARGINFO_END() PHP_DECIMAL_METHOD(isNegative) { PHP_DECIMAL_PARAMS_PARSE_NONE(); - RETURN_BOOL(mpd_isnegative(THIS_MPD())); + + mpd_t *mpd = THIS_MPD(); + + RETURN_BOOL(!mpd_isnan(mpd) && mpd_isnegative(mpd)); } /** diff --git a/tests/php7/methods/isNegative.phpt b/tests/php7/methods/isNegative.phpt new file mode 100644 index 0000000..b181342 --- /dev/null +++ b/tests/php7/methods/isNegative.phpt @@ -0,0 +1,55 @@ +--TEST-- +Decimal::isNegative +--SKIPIF-- + +--FILE-- +isNegative(); + + if ((string) $result !== (string) $expect) { + print_r(compact("number", "result", "expect")); + } +} +?> +--EXPECT-- diff --git a/tests/php7/methods/isPositive.phpt b/tests/php7/methods/isPositive.phpt new file mode 100644 index 0000000..96e0fc2 --- /dev/null +++ b/tests/php7/methods/isPositive.phpt @@ -0,0 +1,55 @@ +--TEST-- +Decimal::isPositive +--SKIPIF-- + +--FILE-- +isPositive(); + + if ((string) $result !== (string) $expect) { + print_r(compact("number", "result", "expect")); + } +} +?> +--EXPECT--