Math::N...tDigits(3)
๐ Math::NumSeq::SqrtDigits โ the digits of a square root ๐
okay bestie so this is a page from the User Contributed Perl Documentation corner of the manual, and it's literally about pulling digits out of a square root one by one. it's giving calculator-girl math and i'm obsessed ๐งฎโจ
๐ธ NAME ๐ธ
Math::NumSeq::SqrtDigits โ the digits of a square root, no cap ๐ซถ
โจ SYNOPSIS โจ
use Math::NumSeq::SqrtDigits;
my $seq = Math::NumSeq::SqrtDigits->new (sqrt => 7);
my ($i, $value) = $seq->next;
like, that's it. that's the whole vibe. ๐
๐ฆ DESCRIPTION ๐ฆ
So basically: it's the sequence of digits that make up the square root of a radicand you hand it. Say you want sqrt(2) in decimal โ you get 1, 4, 1, 4, 2, 1, etc, which is literally 1.41421 etc. iconic behavior tbh ๐
The default is decimal, but you can also pass a "radix" if you're feeling spicy. Right now the current code uses "Math::BigInt" under the hood. (And lowkey a fun fact: for radix 2, 8 and 10, the specific digit conversion methods in BigInt get used, which might be faster than the general case. slay for powers of two ๐โจ)
๐ FUNCTIONS ๐
Peep "FUNCTIONS" in Math::NumSeq for the behaviour that's common to all sequence classes, bestie โ this one only adds its own lil' flavor.
$seq = Math::NumSeq::SqrtDigits->new (sqrt => $s)$seq = Math::NumSeq::SqrtDigits->new (sqrt => $s, radix => $r)
Create and return a fresh new sequence object giving you the digits of sqrt($s). new year new sequence fr fr ๐
$bool = $seq->pred($value)
Return true if $value might occur as a digit in the square root. ๐
Currently this presumes all digits occur, so it's simply "$value >= 0" and "$value < $radix". But okay real talk โ for a perfect square this might be wrong?? and for a non-square, do all digits in fact occur? the manpage is literally asking us. we don't know. the math girlies are still figuring it out ๐ญ (this is the author's own wondering, not me guessing, don't come for me ๐)
๐ BUGS ๐
The current code requires "Math::BigInt" bsqrt(), which may mean you need BigInt 1.60 or higher. (good news tho: that version comes with Perl 5.8.0 and up, so you're probably fine ๐ซถ)
๐ SEE ALSO ๐
Math::NumSeqMath::NumSeq::SqrtEngelMath::NumSeq::FractionDigits- Norman L. de Forest,
"The Square Root of 4 to a Million Places", at Project Gutenberg, <http://www.gutenberg.org/ebooks/3651> โ a whole million places, that's main character energy fr ๐๐
๐ HOME PAGE ๐
<http://user42.tuxfamily.org/math-numseq/index.html> โ go say hi โจ
๐ LICENSE ๐
Copyright 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2019, 2020 Kevin Ryde
Math-NumSeq is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
Math-NumSeq is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. (translation: it's free, but if it breaks, that's on you bestie ๐ญ)
You should have received a copy of the GNU General Public License along with Math-NumSeq. If not, see <http://www.gnu.org/licenses/>.
and that's the whole page, periodt ๐
this was perl v5.42.0, dated 2025-07-25, and it lives in the Math::N...tDigits(3) slot of the manual. mwah, go read some digits ๐ฆโจ
๐ฆ where this page comes from
- fedora 43: perl-Math-NumSeq 75-11.fc43 ยท GPL-3.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms