Fract() behaviour


I want to ask - Why in GLSL was such design decision to make fract() function as


because it gives “incorrect” fraction values for negative arguments. Correct fract() implementation should be like this:

if (x>=0.)
  return x-floor(x)
  return x-ceil(x)

Anybody knows such fract() design decision ??

Thanks in advance.

Same for modulo operation, they are done differently depending on the programming language and sometimes hardware architecture :

Not sure if one is better than the other in the mathematical or design sense, anyway it will depend on what you want to do with it.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.