incbeta icon indicating copy to clipboard operation
incbeta copied to clipboard

1.0 / 0.0 result cannot compile

Open Juddd opened this issue 3 years ago • 6 comments

Why make such a choice to use a return 1.0 / 0.0;

Juddd avatar Jun 10 '22 10:06 Juddd

What compiler are you using and what message does it output?

codeplea avatar Jun 10 '22 14:06 codeplea

@codeplea It get information:

divide or mod by zero

Juddd avatar Jun 11 '22 17:06 Juddd

Please copy/paste your command-line compiler invocation and what it says.

To fix your issue, you can merely change the line to return NAN;.

codeplea avatar Jun 11 '22 23:06 codeplea

I propose INFINITY instead. That is also a C99 macro. It works with Microsoft Visual Studio C++ 2022 in a C project

BartJongejan avatar Dec 09 '23 16:12 BartJongejan

Why prefer INFINITY over NAN?

codeplea avatar Dec 09 '23 16:12 codeplea

Because 1/0 seems to say +infinity. I think it would be reasonable to say that 0/0 is not-a-number.

BartJongejan avatar Dec 09 '23 17:12 BartJongejan