Hacker News new | ask | show | jobs
by tsimionescu 386 days ago
This is a very strange question. With repeating decimals, it is technically possible, though very complicated, to do arithmetic directly on the representations. You have to remember a bunch of extra rules, but it can be done.

However, with numbers that have non-repeating inifinite decimal expansions, it is completely imposible to do arithmetic in the decimal notation. I'm not exagerating: it's literally physically impossible to represent on paper the result of doing 3pi in decimal notation in an unambiguous form other than 3pi. It's also completely impossible to use the decimal expansion of pi to compute that pi / pi = 1.

Here, I'll show you what it would be like to try:

  pi / pi
    =  3.141592653589793238462643383279502884197169399375105820949445923078164062862089986280348253421170679821480865132820664709384460955058223172.... 
Now, of course you can do arithmetic with certain approximations of pi. For example, I can do this:

  pi / pi
    ≈ 3.1415 / 3.1415
    = 1
Or even

  3 × pi 
   ≈ 3 × 3
   = 9
But this is not doing arithmetic with the decimal expansion of pi, this is doing arithmetic with rational numbers that are close enoigh to pi for some purpose (that has to be defined).
1 comments

pi/pi would evaluate to 1 as most proper languages would deal with pi symbolically and not arithmetically.
My point was only that even trivial arithmetic is impossible to do with the infinite decimal representations of irrational numbers.
in python

  import math

  result = math.pi / math.pi
  print(result)     #1.0
bit more long winded than raku, but nearly right

fwiw I want my pi/pi to be 1 (ie an Int) not 1.0 but then I’m a purist

in raku

  say pi/pi;   #1
Sadly, that's just Num.gist showing 1.0 as "1" though.

say (pi/pi).^name; # Num

lol … my bad I should have realized that pi is a Num since it’s an Irrational and a Num over a Num is a Num