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) d

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

Reply via email to