Humus said:Dio said:But there's no point in starting a calculation that generates one.
And "I didn't know it was going to" is not an answer. Coders should know when their code might generate NaN's and avoid them.
The problem with that is that it can be quite expensive to handle division by zero cases. If you instead generate MAX_FLOAT, chances are you'll get a useful enough value so that you don't have to do any extra math just to avoid getting artifacts. Say you're doing a simple projection for a spot light. Somewhere there's going to be a line of division by zeros. If I can just mask away this area along with backlighting the problem goes away. Cheap and easy. If on the other hand I'm getting NAN or INF the artifacts remain and I'll have to explicitely take care of it, unneccesarily wasting computing power.
It seems lot of people see IEEE as the golden standard to reach for. I see IEEE as an old standard with little to no use it practice typically generating more problems than it solves. It's hardly useful on CPUs, but I can live with it. But on GPUs I just don't want it there. A waste of silicon that's making our lives harder.
ERP said:Mostly Nan and Inf are useful for knowing you did your numeric analysis wrong.
I was most displeased when I first started working on Xbox and discovered that X86's don't just throw an exception and stop when they generate inf or Nan.
NaN's are like virus' they are just plain evil by the time you spot one it's usually thousands of instruction after where you screwed up and every variable it touched has been converted to NaN so you have no useful debugging info.
Personally I prefer getting the NaN'a and Inf's in the frame buffer, at least I know there's a problem.
radar1200gs said:As for division by zero, anyone who has done any programming at all knows very well that this is something that simply should not be done in the first instance.
dominikbehr said:ERP said:Mostly Nan and Inf are useful for knowing you did your numeric analysis wrong.
I was most displeased when I first started working on Xbox and discovered that X86's don't just throw an exception and stop when they generate inf or Nan.
NaN's are like virus' they are just plain evil by the time you spot one it's usually thousands of instruction after where you screwed up and every variable it touched has been converted to NaN so you have no useful debugging info.
Personally I prefer getting the NaN'a and Inf's in the frame buffer, at least I know there's a problem.
this should be some help
http://msdn.microsoft.com/library/d...ore98/HTML/_crt__control87.2c_._controlfp.asp
Humus said:radar1200gs said:As for division by zero, anyone who has done any programming at all knows very well that this is something that simply should not be done in the first instance.
Anyone who has done any real programming knows what a pain in the ass it is to take care of this special case every time you perform a division. The only problem is that division by zero is undefined in the science of math. That however doesn't mean we can't define it to something useful in programming tasks, rather than spending cycles having to take care of a rare special case.
Humus said:Anyone who has done any real programming knows what a pain in the ass it is to take care of this special case every time you perform a division. The only problem is that division by zero is undefined in the science of math. That however doesn't mean we can't define it to something useful in programming tasks, rather than spending cycles having to take care of a rare special case.
Humus said:radar1200gs said:As for division by zero, anyone who has done any programming at all knows very well that this is something that simply should not be done in the first instance.
Anyone who has done any real programming knows what a pain in the ass it is to take care of this special case every time you perform a division. The only problem is that division by zero is undefined in the science of math. That however doesn't mean we can't define it to something useful in programming tasks, rather than spending cycles having to take care of a rare special case.
Humus said:Anyone who has done any real programming knows what a pain in the ass it is to take care of this special case every time you perform a division. The only problem is that division by zero is undefined in the science of math. That however doesn't mean we can't define it to something useful in programming tasks, rather than spending cycles having to take care of a rare special case.
Drak said:If you don't want to deal with division by zeros, you can condition your division by adding epsilon to your divisor. If you do want to deal with them, you can let the Infs/NaNs propagate and trace them back.
It would be nice if we had fast functions to set NaNs/Infs in the framebuffer/rendertextures to some specified value such a 0.
Drak said:If you don't want to deal with division by zeros, you can condition your division by adding epsilon to your divisor.
But in terms of graphics algorithms, where are you going to have division by zero?nutball said:Drak said:If you don't want to deal with division by zeros, you can condition your division by adding epsilon to your divisor.
This works fine until you try this with a denominator that happens to be -epsilon.
Simon F said:But in terms of graphics algorithms, where are you going to have division by zero?
nutball said:Drak said:If you don't want to deal with division by zeros, you can condition your division by adding epsilon to your divisor.
This works fine until you try this with a denominator that happens to be -epsilon.
Simon F said:Lighting calcs where the light gets too close? Since that's computing a distance, the value will always be positive and so the epsilon trick should be ok. (In fact, it's probably necessary for realistic modelling since you wouldn't have an infinitely bright light anyway... it would have set fire to the material )
Drak said:I have to admit that I don't usually deal with negative denominators when I'm normalising. Anyway, if that's your cup of tea, take the sign off your denominator, then multiply the end result of the division by the sign.
Oh I agree completely. I certainly made sure Elan/Naomi2 had lighting parameters that could guard against nasty cases.Drak said:Even dividing by very small fractions may result in huge numbers that may not be very useful depending on what you're computing/modelling.
nutball said:Who said anything about normalising?
Humus said:Anyone who has done any real programming knows what a pain in the ass it is to take care of this special case every time you perform a division. The only problem is that division by zero is undefined in the science of math. That however doesn't mean we can't define it to something useful in programming tasks, rather than spending cycles having to take care of a rare special case.