## Why is 0.0 == 0.0 false in REPL but true when executing natively?

0.0 == 0.0 is false when I execute that expression in the interactive REPL:But it's true if I compile and run this program:

## How to determine if string from file is float or double in C++?

I would like to parse a file and determine if the number I've read is float or double. The file I parse is one of the matrices in Matrix Market format (like this: https://sparse.tamu.edu/HB/1138_bus).

## For a positive integer n, is Math.random()*n >= n possible?

According to Why are floating point numbers inaccurate?, floating point numbers has errors.My question is, for a positive integer n, is it possible that Math.random()*n has errors such that its result becomes equals or greater than n?

## Why does setting a const variable (which will be stored with the same value) lead to a different result once divided?

Pretty basic code:Which outputs:As you can see, b and bConst seem to be treated using the same value - i.e. it prints for both the same 0.057762265046662104872599030613855575211346149444580078125 value. So I guess they are "stored" both the same. The only difference is that b is not const.

## Is it possible in floating point to return 0.0 subtracting two different values?

Due to the floating point "approx" nature, its possible that two different sets of values return the same value.

## Why does printf(“%.2f”, (double) 12.555) return 12.55?

I was writing a program where I had to round double to second decimal place. I noticed printf("%.2f", (double) 12.555) return 12.55. However, printf("%.2f", (float) 12.555) returns 12.56. Can anyone explain why this happens?

## Fast way to get a close power-of-2 number (floating-point)

In numerical computation, it is often needed to scale numbers to be in safe range.For example, computing Euclidean distance: sqrt(a^2+b^2). Here, if magnitude of a or b is too small/large, then underflow/overflow can happen.

## Is binary equality comparison of floats correct?

I'm working on different memory block manipulation functions and during benchmarks I noticed, that my implementation of the IsEqualRange(double* begin1, double* end1, double* begin2, double* end2) is much faster then the std::equals(...) on MSVC and GCC as well. Further investigation showed, that doubles and floats are not block compared by...