Math::N...tDigits(3)

๐Ÿ“ฆ
version 75 ยท 2 versions
, in fedora 43

๐Ÿ’– 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::NumSeq
  • Math::NumSeq::SqrtEngel
  • Math::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