## 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...

## Multi line math results different than single line

I was having an issue with some floating point math and I've found that if I do my math on one line, I get -0 passed to tan(), and if I do it across two lines, I get 0 passed to tan(). Have a look:

## What is the idiomatic way to get the index of a maximum or minimum floating point value in a slice or Vec in Rust?

Assumption -- The Vec<f32> does not have any NaN values or exhibit any NaN behavior.Take the following sample set:

## Generate uniformly random float which can return all possible values

An easy way to generate a random float64 in [0,1) is by generating a uniformly random int in [0,2⁵³) and dividing it by 2⁵³. This is essentially what rand.Float64() is doing. However, not all possible float64 values between 0 and 1 can be generated this way: if the value is...