I want to know how N[π, 30] == π
works. The result is True
. I wonder whether the exact number π
is truncated to a $MachinePrecision
number or N[π, 30]
is extended to an exact number in a way similar to the output of this instruction N[Pi, 30] // FullForm
(like stated here).
$\begingroup$
$\endgroup$
8
Equal
: "Approximate numbers with machine precision or higher are considered equal if they differ in at most their last seven binary digits (roughly their last two decimal digits)..." (of the precision of the expreassion, which is the lowest precision present, i.e. 30 digits in your example). $\endgroup$ – Michael E2 Dec 26 '19 at 17:27SetPrecision[N[Pi, 30], 55] == Pi
evaluates toTrue
as well even though naïvely there appears to be a difference of not 7, but 25 digits. $\endgroup$ – Szabolcs Dec 26 '19 at 17:29SetPrecision[N[Pi, 30], 55] - Pi
evaluates to somethign of the order $10^{-54}$. Freak accident? $\endgroup$ – Szabolcs Dec 26 '19 at 17:30N[Pi, 30] // FullForm
are correct, and there are more than 55 of them. So it is equal toPi
to 55 digits. (The internal form of arbitrary precision carries extra guard digits. How many varies.) $\endgroup$ – Michael E2 Dec 26 '19 at 17:30