Skip to content

Commit

Permalink
- Fixed the Convert.to_f() method to convert Math::BigRat objects to …
Browse files Browse the repository at this point in the history
…Math::BigFloat
  • Loading branch information
trizen committed Dec 15, 2015
1 parent 76d78b5 commit a07896d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/Sidef/Convert/Convert.pm
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ package Sidef::Convert::Convert {
*to_number = \&to_n;

sub to_float {
Sidef::Types::Number::Number->new(Math::BigFloat->new($_[0]->get_value));
my ($value) = $_[0]->get_value;
Sidef::Types::Number::Number->new(ref($value) eq 'Math::BigRat' ? $value->as_float : Math::BigFloat->new($value));
}

*to_f = \&to_float;
Expand Down

0 comments on commit a07896d

Please sign in to comment.