Skip to content

Commit

Permalink
fix: handle negative infinity
Browse files Browse the repository at this point in the history
  • Loading branch information
tonytonyjan committed Oct 2, 2017
1 parent b927674 commit 51dc679
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ext/exif/data.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ VALUE srational_to_num(ExifSRational srational){
if(srational.numerator == 0 && srational.denominator == 0)
return DBL2NUM(NAN);
else if(srational.denominator == 0)
return DBL2NUM(INFINITY);
return DBL2NUM(srational.numerator > 0 ? INFINITY : -INFINITY);
else
return rb_rational_new(LONG2NUM(srational.numerator), LONG2NUM(srational.denominator));
}
Binary file modified test/infinity.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions test/test_exif.rb
Original file line number Diff line number Diff line change
Expand Up @@ -230,5 +230,6 @@ def test_nan
def test_infinity
data = Exif::Data.new(IO.read(File.expand_path('../infinity.jpg', __FILE__)))
assert_equal Float::INFINITY, data.exposure_index
assert_equal -Float::INFINITY, data.exposure_bias_value
end
end

0 comments on commit 51dc679

Please sign in to comment.