lib/pdground/extension.rb in pdground-0.1.2 vs lib/pdground/extension.rb in pdground-0.1.3
- old
+ new
@@ -11,5 +11,16 @@
def hisigfig(digits)
format("%.#{digits - 1}e", self).split('e')[0].delete('.')
end
end
+
+# Redefine Integer class to include the same methods as Float
+class Integer
+ def sigfig(digits)
+ to_f.sigfig(digits)
+ end
+
+ def hisigfig(digits)
+ to_f.hisigfig(digits)
+ end
+end