I have 3 string variables that I need to add. a = "5.21", b= "5.22" and c = "5.23". When I try to add i get a string, I need the numerical value
I have tried the following
a = a.to_f => 5.2
b = b.to_f => 5.2
c = c.to_f => 5.2
sum = a + b + c => 15.6
How do i get output 15.66. please help
a,bandcparameters are not all set to "5.2"? ... seems like the #to_f method should return a different value. Maybe the values are changed by some line of code you didn't notice...?.each_char { |c| puts c.ord }. Where did the values ofa,bandccome from?