numeric_limits::espilon returns the difference between 1 and the next double. So, should I understand that the distance between two adjacent doubles is not always the same, for instance between 2 and the next double?
And if yes could I have a piece of explanation ?
The “density” of floating-point numbers decreases a lot as you get farther away from zero.
This is because IEEE floating-point is stored essentially as scientific notation, so range is favored over uniform precision. (If it was uniform precision, it would be fixed-point, not floating-point.)
In other words, numbers are stored in the form Significand * 2exponent, so if the exponent gets large, a small change in the significand produces a large change in the number (and vice-versa).
So no, you can’t assume that the difference between 2 and the next double is the same as epsilon; it isn’t.