OSDN Git Service

refactoring decimal method master
authorTomohiro Nishimura <tomohiro68@gmail.com>
Mon, 10 May 2010 06:00:31 +0000 (15:00 +0900)
committerTomohiro Nishimura <tomohiro68@gmail.com>
Mon, 10 May 2010 06:00:31 +0000 (15:00 +0900)
lib/mint/generator/arithmetic_base.rb

index f18d085..a46913b 100644 (file)
@@ -83,7 +83,10 @@ module Mint::Generator
       unless use_integer
         integer_part = create_integer(options[:min].to_i, options[:max].to_i, false)
       end
-      decimal_part = 1 + rand((10**options[:digits]) - 1)
+      decimal_part = 0
+      begin
+        decimal_part = rand(10**options[:digits])
+      end while decimal_part == 0
       ("#{integer_part}.#{decimal_part}".to_f * sign(options[:minus])).to_s
     end