On 2023-04-22 16:34, Ben Pfaff wrote:
determine whether converting 'd' to 'long' would yield a 'long' with the same value as 'd'
LONG_MIN - 1.0 < d && d < LONG_MAX + 1.0 && d == (long) dOn all practical platforms this should avoid undefined behavior and works correctly even if rounding occurs. You can replace "d == (long) d" with "d == floor (d)" if you prefer.