Skip to content

Commit

Permalink
- Fixed the deparsing of infinite and "NaN" numbers.
Browse files Browse the repository at this point in the history
  • Loading branch information
trizen committed Sep 4, 2015
1 parent b95ac45 commit 274a8db
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/Sidef/Deparse/Sidef.pm
Original file line number Diff line number Diff line change
Expand Up @@ -340,10 +340,11 @@ package Sidef::Deparse::Sidef {
}
elsif ($ref eq 'Sidef::Types::Number::Number') {
my $value = $obj->get_value;
$code .= ref($value) ? ref($value) eq 'Math::BigRat' ? $value->numify : $value->bstr : $value;
my $num = ref($value) ? ref($value) eq 'Math::BigRat' ? $value->numify : $value->bstr : $value;
$code = lc($num) eq 'inf' ? '0.inf' : lc($num) eq 'nan' ? '0.nan' : $num;
}
elsif ($ref eq 'Sidef::Types::Array::Array' or $ref eq 'Sidef::Types::Array::HCArray') {
$code .= $self->_dump_array($obj);
$code = $self->_dump_array($obj);
}
elsif ($obj->can('dump')) {
$code = $obj->dump->get_value;
Expand Down

0 comments on commit 274a8db

Please sign in to comment.