in reply to Re^4: IF condition with a range (updated)
in thread IF condition with a range

Frankly with Inf, it's probably a good thing if your code doesn't treat two infinite values as being equal

That's a rather novel approach to overflow, and one that I would discourage.

Similarly, wrt to underflow, one could then say:

Frankly with 0, it's probably a good thing if your code doesn't treat two zero values as being equal.

my $x = 1e-5000; # 0
my $y = 1e-5100; # 0

print "equal\n" if $x==$y; # says "equal" even though mathematically they are not

That's also an approach that I would discourage.

Cheers,
Rob
  • Comment on Re^5: IF condition with a range (updated)

Replies are listed 'Best First'.
Re^6: IF condition with a range (updated)
by tobyink (Canon) on Jul 17, 2018 at 11:38 UTC

    Well, the difference between 1e-5000 and 1e-5100 is pretty small. For most intents and purposes, there is no difference.

    The difference between 6**6**6 and 7**7**7 is a lot bigger. By my calculations, the latter is 659669 orders of magnitude bigger than the former. (That is, to approximate 7**7**7, you'd need to add 659669 zeroes to the end of 6**6**6.)

      Well, the difference between 1e-5000 and 1e-5100 is pretty small. For most intents and purposes, there is no difference

      Heh ... I thought this was about "mathematical equality", but suddenly it's now also about "intents and purposes".
      For double precision NVs I could have chosen much larger values of (say) 1e-324 and 1e-325 ... but you're probably not going to be swayed by that, anyway ;-)

      By my calculations, the latter is 659669 orders of magnitude bigger than the former

      Yep, I get the same:
      C:\>perl -MMath::MPFR -le "$x=Math::MPFR->new(6 ** 6); print 6 ** $x; 2.6591197721532269e36305 C:\>perl -MMath::MPFR -le "$x=Math::MPFR->new(7 ** 7); print 7 ** $x; 3.7598235267837884e695974

      Cheers,
      Rob