A mysterious divide by 0 error

Am I missing something obvious, or is this as bizarre as it seems?

This code started throwing divide by 0 errors. The ifs and ?: are what I added to try and stop it. It's still doing it, and what's more, I added a debug message just above it which tells me that, in fact, dist is not 0 when this happens.

if(u!=0) u = u/((dist==0) ? 1 : dist);

It's supposed to be dividing u by dist. Since dist could conceivably be 0, I added the (dist==0) ? 1 : part.
Then it kept doing it and I noticed the first time u was 0, so I added the if. It seemed kinda pointless, since u being 0 should have no effect, but I'm kinda grasping at straws at this point.
Did I miss something that makes this code vulnerable to divide by 0, or is my computer refusing to eat its vegetables?



_______________________________________________
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : sneak via Audiogames-reflector

Reply via email to