You could use math.floor(x) From the Lua Reference Manual: Returns the largest integer smaller than or equal to x.

Float and double datatype in Java

The Wikipedia page on it is a good place to start. To sum up: float is represented in 32 bits, with 1 sign bit, 8 bits of exponent, and 23 bits of the significand (or what follows from a scientific-notation number: 2.33728*1012; 33728 is the significand). double is represented in 64 bits, with 1 sign bit, 11 bits of … Read more

Difference between decimal, float and double in .NET?

float and double are floating binary point types. In other words, they represent a number like this: The binary number and the location of the binary point are both encoded within the value. decimal is a floating decimal point type. In other words, they represent a number like this: Again, the number and the location of the decimal point are both encoded within the value – that’s … Read more

Difference between decimal, float and double in .NET?

float and double are floating binary point types. In other words, they represent a number like this: The binary number and the location of the binary point are both encoded within the value. decimal is a floating decimal point type. In other words, they represent a number like this: Again, the number and the location of the decimal point are both encoded within the value – that’s … Read more

C++: How to round a double to an int?

add 0.5 before casting (if x > 0) or subtract 0.5 (if x < 0), because the compiler will always truncate. C++11 also introduces std::round, which likely uses a similar logic of adding 0.5 to |x| under the hood (see the link if interested) but is obviously more robust. A follow up question might be why the float … Read more