From: Gui Djos Date: 2010-02-16T09:56:54+09:00 Subject: Newbie needs help Heya fellas. I've coded C, Java and perl for a while now, but I'm completely new to Ruby (started off today ;) ), and I have an error that's bugging me. Basically, the script is intented to calculate the radices of an equation using the Baskara method. Ive tried working with Float() conversions, and that hasn't given me the right results either. The code is as follows: [code] def resolveBaskara(a, b = 1, c = 1) if a == 0 puts "Not a second degree equation.\n\n" return end delta = x_1 = x_2 = 0 delta = Float((b ** 2) - (4 * a * c)) if delta < 0 puts "Negative Delta.\n\n" return end x_1 = Float((-1 * b + delta ** 1/2)/2 * a) if delta == 0 x_2 = x_1 else x_2 = Float((-1 * b - delta ** 1/2)/2 * a) end return x_1,x_2 end print "Give a value for A: " A = gets.chomp print "Give a value for B: " B = gets.chomp print "Give a value for C: " C = gets.chomp x1,x2 = resolveBaskara(A.to_f,B.to_f,C.to_f) if x1 != nil puts "Raizes: \n\tX1: #{x1}" end if x2 != nil puts "\n\tX2: #{x2}" end [/code] Again, I'm new to this, so forgive any silly mistakes / bad practices. I'll learn it when I learn it. -- Posted via http://www.ruby-forum.com/.