The code (lines 613 to 639) shows that the intention was
to return NaN for non-integers. However, line 641:
$self->{sign} = '+' if $$miv eq '0';
defeats this when the integer part is 0, hence the inconsistency. To keep the old behaviour, one would have to change it as follows:
$self->{sign} = '+' if $$miv eq '0' && $self->{sign} ne $nan;
To always do a truncation and not return NaN as suggested above, one has to remove the lines flagging the NaN:
@@ -613,13 +613,8 @@
if ($$mfv ne '') # e <= 0
{
# fraction and negative/zero E => NOI
- if ($_trap_nan)
- {
- require Carp; Carp::croak("$wanted not an integer in $class");
- }
#print "NOI 2 \$\$mfv '$$mfv'\n";
return $upgrade->new($wanted,$a,$p,$r) if defined $upgrade;
- $self->{sign} = $nan;
}
elsif ($e < 0)
{
@@ -628,17 +623,12 @@
$e = abs($e);
if ($$miv !~ s/0{$e}$//) # can strip so many zero's?
{
- if ($_trap_nan)
- {
- require Carp; Carp::croak("$wanted not an integer in $class");
- }
#print "NOI 3\n";
return $upgrade->new($wanted,$a,$p,$r) if defined $upgrade;
- $self->{sign} = $nan;
}
}
}
All Line numbers refer to version 1.9991, which my distribution ships but CPAN does not yet (?!).