Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I noticed this comment in the "notes.html":

  // Set the floating point precision ...
  _controlfp                           
  // Question: Why do that for every frames ? Probably because precision is altered during the loop execution.
  // Answer: The is no other call to this function. It appears that floating point precision remains the same during program execution.
I seem to vaguely recall reading something about some versions of Windows not preserving the FPU state across task switches. Could it be that this call to configure the FPU for every frame is a workaround for that?


http://gafferongames.com/networking-for-game-programmers/flo...

Search for _controlfp.. seems some MS API calls could change it.


I've also experienced Windows / DirectX API's use MMX, hence the floating point code I was using (x87 FPU) required a femms instruction before it to change back from MMX state.

This just goes to show that if you need a particular state on a processor (CPU, FPU, GFX, etc) you need to set it explicitly before use.


Maybe it's because the calls to functions in DLLs could, in theory, change it?


You may mix up with linux (which does not save the FPU state: that's why you can't use most floating point operations in the kernel).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: