What’s the difference between a single precision and double precision floating point operation?

What is the difference between a single precision floating point operation and double precision floating operation? I’m especially interested in practical terms in relation to video game consoles. For example, does the Nintendo 64 have a 64 bit processor and if it does then would that mean it was capable of double precision floating point … Read more

What does gcc’s ffast-math actually do?

I understand gcc’s –ffast-math flag can greatly increase speed for float ops, and goes outside of IEEE standards, but I can’t seem to find information on what is really happening when it’s on. Can anyone please explain some of the details and maybe give a clear example of how something would change if the flag … Read more

Which is the first integer that an IEEE 754 float is incapable of representing exactly?

For clarity, if I’m using a language that implements IEE 754 floats and I declare: float f0 = 0.f; float f1 = 1.f; …and then print them back out, I’ll get 0.0000 and 1.0000 – exactly. But IEEE 754 isn’t capable of representing all the numbers along the real line. Close to zero, the ‘gaps’ … Read more

Meaning of delta or epsilon argument of assertEquals for double values

I have a question about JUnit assertEquals to test double values. Reading the API doc I can see: @Deprecated public static void assertEquals(double expected, double actual) Deprecated. Use assertEquals(double expected, double actual, double delta) instead. (Note: in older documentation versions, the delta parameter is called epsilon) What does the delta (or epsilon) parameter mean? 8 … Read more

Compare double to zero using epsilon

Today, I was looking through some C++ code (written by somebody else) and found this section: double someValue = … if (someValue < std::numeric_limits<double>::epsilon() && someValue > -std::numeric_limits<double>::epsilon()) { someValue = 0.0; } I’m trying to figure out whether this even makes sense. The documentation for epsilon() says: The function returns the difference between 1 … Read more

Format Float to n decimal places

I need to format a float to “n”decimal places. was trying to BigDecimal, but the return value is not correct… public static float Redondear(float pNumero, int pCantidadDecimales) { // the function is call with the values Redondear(625.3f, 2) BigDecimal value = new BigDecimal(pNumero); value = value.setScale(pCantidadDecimales, RoundingMode.HALF_EVEN); // here the value is correct (625.30) return … Read more