From: Tomi Zzzz Date: 2008-09-14T21:18:45+09:00 Subject: how do deal with huge numbers and keep them accurate? Hello all, I wrote the following code: require "bigdecimal" require "bigdecimal/math" include BigMath odd = gets.chomp.to_f result = odd/3.0 puts result.to_f blank = gets.chomp the code works just fine when the input is upto 15 digits, but afterwards the code fails to give the correct output. a few good examples: odd=1231231 result=410410.333333333 odd=123123123123121 (15 digits) result=41041041041040.3 so far so good,now: odd=1231231231231231 (16 digits) result=4.1041041041041e+014 (given with no remainder) [It's a wrong answer! the result should have been --- 410410410410410.33333] What do i need to chance in the code to make it happen? in the future i should deal with larger numbers and the accuracy is essential. thanks in advanced, tomi. -- Posted via http://www.ruby-forum.com/.