M
Martin Brown
Guest
On 02/05/2022 22:02, Lasse Langwadt Christensen wrote:
It should worry about the skill of the programmer who wrote the code.
>> Log it, skip the update, and press on to the next measurement.
+1
Or maybe just count it. Not doing the divide saves enough time to do
something else that is *directly* under the programmers control.
Divides particularly and sometimes multiplies have the possibility of
overflow or underflow if their inputs are unfriendly.
> hoping that that doesn\'t slow the system down to much
Division even on the current crop of fast processors is already so slow
that explicitly defending against division by zero and the resulting
trap handling recovery is invariably faster than the alternative.
Many times you can prove that the divisor will not ever be zero but if
you can\'t then you should decide exactly how to handle that exception.
Division is roughly an order of magnitude slower than any of the other
primitive operations on today\'s CPU\'s - it was even worse in the past.
+,-,* now execute in a single cycle and in combination with branch
prediction and speculative execution can appear to execute in fractions
of a cycle provided that the data they need is available quickly enough.
--
Regards,
Martin Brown
mandag den 2. maj 2022 kl. 22.52.48 UTC+2 skrev Phil Hobbs:
jla...@highlandsniptechnology.com wrote:
On Sun, 1 May 2022 20:27:33 -0700 (PDT), whit3rd <whi...@gmail.com
wrote:
On Saturday, April 30, 2022 at 1:23:21 PM UTC-7, legg wrote:
On Sat, 30 Apr 2022 10:47:30 -0700 (PDT), Ricky
gnuarm.del...@gmail.com> wrote:
On Saturday, April 30, 2022 at 12:11:41 PM UTC-4, jla...@highlandsniptechnology.com wrote:
I wrote an s32.32 saturating math package for the 68K that always did
what was most reasonable.
0/0 = 0
I\'m sure no one can explain why 0/0 = 0 makes sense. Zero does not represent just exactly zero. Just as 1 is the range from 1/2 to 1-1/2, zero is the range from -1/2 to +1/2.
If the denominator is not zero, as the numerator approaches zero, yes, in the limit, the result approaches zero. But if the numerator is not zero, as the denominator approaches zero, in the limit, the result approaches infinity. So why would 0/0=0 make sense?
I would have expected 0/0=1 ie no rational difference.
That\'s the case if you consider lim x/x as x approaches zero. But,
what of the limit of 2x/x, or -x/x, as x approaches zero? NAN is the
best way to get a thinking human to understanding what the computer
is trying to express.
What does a control system do when the heater voltage is computed to
be NAN?
It should worry about the skill of the programmer who wrote the code.
>> Log it, skip the update, and press on to the next measurement.
+1
Or maybe just count it. Not doing the divide saves enough time to do
something else that is *directly* under the programmers control.
Divides particularly and sometimes multiplies have the possibility of
overflow or underflow if their inputs are unfriendly.
> hoping that that doesn\'t slow the system down to much
Division even on the current crop of fast processors is already so slow
that explicitly defending against division by zero and the resulting
trap handling recovery is invariably faster than the alternative.
Many times you can prove that the divisor will not ever be zero but if
you can\'t then you should decide exactly how to handle that exception.
Division is roughly an order of magnitude slower than any of the other
primitive operations on today\'s CPU\'s - it was even worse in the past.
+,-,* now execute in a single cycle and in combination with branch
prediction and speculative execution can appear to execute in fractions
of a cycle provided that the data they need is available quickly enough.
--
Regards,
Martin Brown