Dan Liew
1 min readDec 1, 2016

--

A small note about adding +0.0to an expression which you say should have essentially no impact. There is no impact most of the time but there are a few exceptions that are worth being aware of:

  • If the expression has the value -0.0(yes IEEE-754 has a plus and minus zero) then adding +0.0to it changes the sign of the expression to positive. This is unlikely to cause a problem because most people check the sign by doing x >= 0 which returns true for -0.0. The problem is observable if you use the signbit() function to check the sign.
  • If the expression is a signalling NaN adding +0.0 to it will turn it into a quiet NaN and raise an invalid operation exception. This is very unlikely to ever be a problem though as I’m not sure GLSL has any support for IEEE-754 exceptions or even cares about the distinction between signalling and quiet NaN.

--

--