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??
rational?
UPDATE: Even (rational? (sqrt 3))reports#t
(rational? (sqrt 3))
#t
, pi, , . , :
pi
- . , , , , + inf.0 ( ), + inf.f( ), -inf.0 ( ), -inf.f( ), + nan.0 (-) + nan.f( ). , , , .
, . ( NaN), , , , .
, Racket rational?, . , Julia Clojure, , , . , , , .
, NaN, . finite, Racket rational.
finite
rational
Source: https://habr.com/ru/post/1688328/More articles:Встроенное изображение электронной почты, показанное в выпуске не разработки - ruby-on-railswhy array_filter is not working? - arraysNmap IP and OUI Provider - awkCalling overloads of non-member statements - c ++Браузер зависает при разборе дат - javascriptКак я могу получить значение от обработчика завершения iOS Swift 3 - iosWhat is the difference between java dotted arguments (e.g. -D) and no dash? - javaIntellisense not working for .vue files - typescriptAn initialization error from an incompatible IOCTL function pointer in the Linux kernel 4.8.0-53-generic Linux Mint 64 bit - linuxKoa.js and streaming. How do you handle errors? - javascriptAll Articles