Why is Racket reporting that π is rational?

As any certified mathematician can confirm, pi is irrational.

But still:

Welcome to Racket v5.3.6.
> pi
3.141592653589793
> (rational? pi)
#t

This is because the representation of pi in the basic floating-point format of the machine has limited precision and therefore can always be expressed as some p / q, where q is 10 ^ n and n is the precision of the representation?

If so, how can any amount forced by Racket (or another similar pattern of behavior) ever be considered anything other than rational? And therefore, why bother with a function rational??

UPDATE: Even (rational? (sqrt 3))reports#t

+4
source share
1 answer

, pi, , . , :

- . , , , , + inf.0 ( ), + inf.f( ), -inf.0 ( ), -inf.f( ), + nan.0 (-) + nan.f( ). , , , .

, . ( NaN), , , , .

, Racket rational?, . , Julia Clojure, , , . , , , .

, NaN, . finite, Racket rational.

+3

Source: https://habr.com/ru/post/1688328/


All Articles