From: Eric Wilhelm <[EMAIL PROTECTED]>
> # The following was supposedly scribed by
> # David Golden
> # on Monday 28 February 2005 07:07 pm:
>
> >Which would you prefer?
> >
> >á á $ perl -le '$x=1/0; print $x+1' á á
> >á á Illegal division by zero at -e line 1.
> >
> >or
> >
> >á á $ perl -le '$x=1/0; print $x+1' á á
> >á á 1
>
> I like the one where you get the mathematically-correct (or at least
> mathematically-useful) infinity.
>
> $perl -le 'use bigint; $x = 1/0; print $x+1'
> inf
And is it +inf or -inf?
Let's see
1/1 = 1
1/0.1 = 2
1/0.01 = 4
1/0.001 = 8
...
lim( 1 / (1/10^n)) for n->inf = inf
vs.
1/-1 = -1
1/-0.1 = -10
1/-0.01 = -100
1/-0.001 = -1000
...
lim( 1 / -(1/10^n)) for n->inf = -inf
So, how did we get to the 0? Did we go from positive numbers or
negative numbers? And is the result positive or negative infinity?
> $perl -le 'use bigint; $x = 1/0; print 1/$x'
> 0
Yep, in this case we know the final result "should" be 0, no matter
whether we define N/0 as plus or minus infinity, but ...
What's (inf - inf)? What's (inf / inf)? What's (inf < inf)?
No you do not want to start counting with infinities, unless you
really know what kind of beasts are you unleashing.
Jenda
===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery