On Tue, 12 Nov 2024 17:25:14 +0100 (CET)
Michael Matz <m...@suse.de> wrote:

> Other values for the divisor will also produce Inf.  If your goal was to 
> avoid getting Inf, then checking for equality with zero _won't_ do:

Yes you are correct, there are many different ways to overflow and
underflow a floating point number. It depends on the context and may
require different checks. In fact, if you program in Ada, then it
allows you to specify the precision of a floating point type. The
compiler then automatically chooses the best format: 32-bit, 64-bit,
128-bit, etc.

> As this very discussion shows the warning seems to be quite worthwhile 
> actually.  As Joseph says, if your programming/mental model uses IEEE 
> floats as real approximations: use the warning and don't check for 
> (non)equality (normally range checks would be in order); if you're using 
> them as IEEE floats, don't use the warning.

Actually I like to enable all warnings, I was simply looking for a way
to disable them for specific cases, which I now discovered can be done
with GCC pragmas.

Reply via email to