Follow Slashdot stories on Twitter

 



Forgot your password?
typodupeerror
×

Comment Re:Scientific worldview undermining own credibilit (Score 1) 668

Come back when you find a repeatable RCT of a homeopathic remedy that shows an effect better than placebo

Easy. Just test a combination of various homeopathic agents, with one of them actually being a real drug (under a fancy homeopathic name) at high enough concentration to have an actual effect.

I have seen studies done this way. Always check the homeopathic medicine in question for barely diluted, real drugs.

Comment Re:I'm with you to some extent (Score 1) 1067

Could you give an example of when x/0 can be safely treated as 0?

a) The program needs to process bursts incoming data quickly and timely, and it is known that only nonzero output values are valid. The program combs through received data later, when there is time.

b) You need to feed an audio DAC or something, and outputting 0 will result in a barely noticable glitch, but missing several samples due to exception handling will produce a very noticable acoustic artefact.

Comment Re:Infinity (Score 1) 1067

Of course. Then do your check for zero before the division, if your latency requirements can handle it. If either option doesn't meet spec, then your specifications are where the "bug" is...

Or maybe you have bursts of data coming in that needs to be processed in a timely manner (leaving no time for exeptions or even checks), followed by periods in which you can comb through the data packets and deal with cases of division by zero (e.g. if you know that the result is normally nonzero, any zeros showing up in your data indicate that these samples need to be handled separately).

It's all a matter of your application.

Comment Re:Infinity (Score 1) 1067

Fix your damn program to check for a dividend of zero, or at least trap the exception and handle it then.

If you have the CPU cycles for this, it is the better option. Depending on the application, you may not have this luxury (really low latency signal processing where trapping an exception will break the real-time behavior of the system).

Comment Re:Idiot (Score 1) 1067

It is not trivial, and in real world situations could be deadly.

Not ignoring the problem could be deadly, too, or at least very costly. It all depends on the application.

Why do you think ARM put a mode in their CPUs where they just return zero on a division by zero? Does ARM leave their CPU design to idiots? I don't think so.

Comment Re:Idiot (Score 1) 1067

Would you prefer the subroutine to report the speed as 0

Yes. Because other parts of the cruise control algorithm can recognize a speed of zero as a point where the cruise control should not be operating at all and disengage it.

The other options would be:

Report an arbitrary value. This leads to horrible results as the arbitrary value may be below the set speed, but still in a range where the cruise control operates.

Report the maximum value. This may lead to funny results if the programmer did not pay close attention to signed/unsigned datatypes.

Do random stuff, crash, require restart before cruise control can be re-engaged: This doesn't immediately lead to horrible results, but to lots of unhappy customers wondering why their car needs resets/power cycling like their Windows computer does.

Comment Re:What I don't get is... (Score 1) 1067

Why does the submitter suggest "zero" as the output for division by zero? How is that a better answer than 23?

Statistically, returning zero usually yields less horrible consequences than returning an arbitrary non-zero number.

If the result of the division is used in further calculations, e.g. in a product, a zero won't cause additional undefined behavior by signed integer overflows, etc.

Comment CPUs do have a setting for that. (Score 1) 1067

ARMs let you chose if you want a division by zero to result in an exception or in a result of zero (DIV_0_TRAP bit).

Of course, you need to get down to assembly to mess with this setting, since most programming languages specify a behavior in this case, or behave in an unspecificed way.

Then again, dividing by zero usually means that there's something wrong with your design.

Slashdot Top Deals

I program, therefore I am.

Working...