lib/sane/float.rb in sane-0.22.0 vs lib/sane/float.rb in sane-0.23.0
- old
+ new
@@ -1,7 +1,15 @@
if RUBY_VERSION < '1.9.2'
class Float
def inspect
- "%.20f" % self # big!
+ big = "%.20f" % self # big!
+ small = "%f" % self
+
+ if small.to_f == self
+ small.sub! /0+$/, ''
+ small.sub /\.$/, '.0'
+ else
+ big
+ end
end
end
end
\ No newline at end of file