Although compute shaders kind of imply that you use a GPU and GLSL version (> 1.30) that does IEEE compliant floating-point math, this is not something you can take for granted, unluckily. So... here be dragons.
Your reasoning from a C++ point of view quoting the C++ reference is reasonable and correct, but it omits a small but important sentence: "If the implementation supports IEEE floating-point arithmetic (IEC 60559),". This small sentence highlights that it's neither a C++ requirement (just a coincidence since IEEE 754 asks for it, and usually C++ implementations comply with IEEE), and it's not a strict guarantee either (it is perfectly allowable for a C++ implementation to not implement IEEE 754).
Further, GLSL is not C++. This may come as a surprise with arithmetic because although it obviously isn't the same language, one can expect that math still works the same, can't one?
Well, no. pow(x, y)
is defined (although 8.2 on which the online man page is based does not explicitly say so) as exp2(x*log2(x))
in GLSL. It inherits its precision from the forementioned expression as stated in 4.7.1. It is not stated that pow(1, x)
equals 1
.
Now, expanding the above expression with the presumably correct intermediate results, the correct result should be +INF
, since log2(+INF) = +INF
, and 1*+INF
is still +INF
, and exp2(+INF) = +INF
.
But, the standard doesn't really define that. It only explicitly (un)defines zero exponents.