[sup-talk] Util - Fixnum num_digits is wrong

Ian Taylor itaylor at uark.edu
Mon Dec 3 03:25:15 EST 2007


Probably wasn't causing any problems, but is wrong.

===================================================================
--- lib/sup/util.rb     (revision 737)
+++ lib/sup/util.rb     (working copy)
@@ -299,7 +299,7 @@
 class Fixnum
   def num_digits base=10
     return 1 if self == 0
-    1 + (Math.log(self) / Math.log(10)).floor
+    1 + (Math.log(self) / Math.log(base)).floor
   end
   
   def to_character

-- 
Ian Taylor


More information about the sup-talk mailing list