0

Why would you wver need to use Math.floor()?

The use of Math.floor() is to round a double down to a integer value while maintaining its type. why would you not just cast a double as an int, and have it truncated automatically?

15th Feb 2017, 10:15 PM
Nolan Batten
Nolan Batten - avatar
1 Answer
0
Doubles can store larger numbers than integers, so you can't just cast it to int without risking an overflow. Also doubles can have the value 'infinity' and 'NaN', integers can't.
16th Feb 2017, 12:23 AM
Robobrine
Robobrine - avatar