Ruud H.G. van Tol on Sat, 14 Dec 2024 12:07:36 +0100
|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
- To: pari-users <pari-users@pari.math.u-bordeaux.fr>
- Subject: digits of a float
- From: "Ruud H.G. van Tol" <rvtol@isolution.nl>
- Date: Sat, 14 Dec 2024 12:07:29 +0100
- Delivery-date: Sat, 14 Dec 2024 12:07:36 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=simple/simple; d=isolution.nl; s=soverin; t=1734174450; bh=F9BPg+Xg8lm0djlooEECb8Do/ERNnTtNkDWxs+h4AYU=; h=Date:To:From:Subject:From; b=Dnkww3mO6Z6QCvbG5vPhrq8FbragCM6OIBiEhWr1u6kxV6aJjgR4kTCDhhQN4S4Wo AzOtUCM65/VKhbfWWCKTJY16HEbTfzMr1APyiIH7q/1WuzzCrnBI7NMVZVLVa+zVzb dOzFx5yYEdm3m/1u65eBXEa1NGXkDKIoEWEdpmCFk220RmqT2hBX1N1wTeD6HgV2s+ kdK5u8e4hBbyDIxjlXTkqCRTaE9fPmSYEuoU7e45Akn1ngIrioVRISAyfEmsDRLvSq Ohuh7r/R78+VHNolGWcugpX9z2UKQy7OzG5xYzqzrTKoo6LTfWbP67HbQhuM5i0xIQ dncQVLlgPL5Sw==
How to properly isolate a digit of a float?
Example:
? my(n=19437); localprec(n+2); Pi *10^(n-1) \1 %10
%4 = 7
? my(n=19437); localprec(n+3); Pi *10^(n-1) \1 %10
%5 = 6
That type of code depends on the number of 9-digits in the decimal
expansion of the value.
See also https://oeis.org/A000796, which uses localprec(n*6\5+29).
What clean ways are there?
-- Ruud