$x;
}
+sub bsgn {
+ # Signum function.
+
+ my $self = shift;
+
+ return $self if $self->modify('bsgn');
+
+ return $self -> bone("+") if $self -> is_pos();
+ return $self -> bone("-") if $self -> is_neg();
+ return $self; # zero or NaN
+}
+
sub bneg
{
# (BINT or num_str) return BINT
$x->bneg(); # negation
$x->babs(); # absolute value
+ $x->bsgn(); # sign function (-1, 0, 1, or NaN)
$x->bnorm(); # normalize (no-op in BigInt)
$x->bnot(); # two's complement (bit wise not)
$x->binc(); # increment $x by 1
#!/usr/bin/perl -w
use strict;
-use Test::More tests => 3623;
+use Test::More tests => 3635;
BEGIN { unshift @INC, 't'; }
} elsif ($f eq "bone") {
$try .= "\$x->bone('$args[1]');";
# some unary ops
- } elsif ($f =~ /^b(nan|floor|ceil|sstr|neg|abs|inc|dec|not|sqrt|fac)$/) {
+ } elsif ($f =~ /^b(nan|floor|ceil|sstr|neg|abs|sgn|inc|dec|not|sqrt|fac)$/) {
$try .= "\$x->$f();";
} elsif ($f =~ /^(numify|length|stringify|as_hex|as_bin)$/) {
$try .= "\$x->$f();";
-1:1
+123456789:123456789
-123456789:123456789
+&bsgn
+NaN:NaN
++inf:1
+-inf:-1
+0:0
++123456789:1
+-123456789:-1
&bcmp
bcmpNaN:bcmpNaN:
bcmpNaN:0:
#!/usr/bin/perl -w
use strict;
-use Test::More tests => 3623 + 6;
+use Test::More tests => 3635 + 6;
use Math::BigInt lib => 'Calc';
#!/usr/bin/perl -w
use strict;
-use Test::More tests => 3623
+use Test::More tests => 3635
+ 5; # +5 own tests
BEGIN { unshift @INC, 't'; }