There are many instances where you will need to round down even if the number is closer to an upper whole number.
Ex. You have a 35ft wide road. Each lane on a road has to be exactly 12 ft, anything less than that won't be allowed by road design codes. How many lanes can you fit in the road? 35ft/12ft =2.917 however since you cannot have a lane that is less than 12 ft you can only fit 2 lanes. Hence you will need to round 2.917 down to 2 in order to get the correct answer.
As stated above, rounding has rules to follow and rounding 2.917 would yield 3.
There are other math functions that should be used. In this case, the Floor() function is perfect as Floor(2.917) = 2.
@BenLoosli wrote:
As stated above, rounding has rules to follow and rounding 2.917 would yield 3.
There are other math functions that should be used. In this case, the Floor() function is perfect as Floor(2.917) = 2.
No! Floor(2.917) would throw an error! You have to use floor(2.917)=2 or Floor(2.917,1)=2.
Its like beating a dead horse as Viktor gave the correct answer in the first reply already more than 20 years ago. The discussion after that if using "floor" should be considered as "rounding" seems to be just a linguistic problem about the exact meaning of "rounding".
However, it is quite common to describe what "floor" does as "rounding off" or "rounding down".
See https://en.wikipedia.org/wiki/Rounding#Rounding_down for example.
For positive numbers you may also use "trunc" or "Trunc" to achieve the same effect.
And, even if jmG has not been a participant in this forum for a long time, let me say that it may also make sense in some cases to round down 1.9 to zero if you are only interested in multiples of 10 smaller or equal to the number:
Its not necessarily "worst case" 🙂