Reputation: 223
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?
Upvotes: 15
Views: 15333
Reputation: 1063
if mynumber >= 0 then
mynumber = mynumber.floor
else
mynumber = 0 - mynumber
mynumber = mynumber.floor
mynumber = 0 - mynumber
end
Upvotes: 1
Reputation: 1026
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
Upvotes: 22