qoa icon indicating copy to clipboard operation
qoa copied to clipboard

Divide by 0 undefined in C99

Open thatcosmonaut opened this issue 2 years ago • 0 comments

The C99 spec states that

The result of the / operator is the quotient from the division of the first operand by the second; the result of the % operator is the remainder. In both operations, if the value of the second operand is zero, the behavior is undefined.

In qoaconv.c L270:

double psnr = 1.0/0.0;

This refuses to compile on some compilers like MSVC.

Changing 1.0/0.0 to the INFINITY macro seems to work fine.

thatcosmonaut avatar May 03 '23 23:05 thatcosmonaut