I need to compare a data set in which one batch of data came with currency with decimals such as 246.54 the new data removes the decimals, does not round up, and has just 246... so I need to remove the decimals from the first batch so I can compare. How would I do this without rounding up?
Use the floor function. It gives the first integer smaller than or equal to whatever number you feed it.
1.9.3-p194 :003 > i = 246.54
=> 246.54
1.9.3-p194 :004 > i.floor
=> 246
if mynumber >= 0 then
mynumber = mynumber.floor
else
mynumber = 0 - mynumber
mynumber = mynumber.floor
mynumber = 0 - mynumber
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With