Math::N...nversion(3)

πŸ“¦
version 75 Β· 2 versions
, in fedora 43

✨ NAME ✨

Math::NumSeq::RadixConversion β€” it's giving radix conversion, bestie πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

use Math::NumSeq::RadixConversion;
my $seq = Math::NumSeq::RadixConversion->new (from_radix => 2,
                                              to_radix => 10);
my ($i, $value) = $seq->next;

πŸ’œ DESCRIPTION πŸ’œ

okay so this sequence is literally just the index i, but converted from one radix to another. no cap. the default vibe is from binary to decimal, and it goes like this:

0, 1, 10, 11, 100, 101, 110, 111, 1000, 1001, 1010, 1011, ...
starting i=0

so like, for example, i=3 in binary is 0b11, and that gets interpreted as decimal for value 11, ie. eleven. iconic behavior honestly πŸ’…

when from_radix < to_radix the effect is to give values which in to_radix use only the digits of from_radix. the default is all integers which in decimal use only the binary digits, ie. 0 and 1. that's it, that's the whole set 🫢

when from_radix > to_radix the conversion is a reduction. the calculation is still a breakdown and re-assembly:

i = d[k]*from_radix^k + ... + d[1]*from_radix + d[0]
value = d[k]*to_radix^k + ... + d[1]*to_radix + d[0]

but because to_radix is smaller the value is smaller than the index i. for example from_radix=10 and to_radix=8 turns i=345 into value=3*8^2+4*8+5=229. math is mathing πŸ”₯


🌸 FUNCTIONS 🌸

see "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence classes. (iykyk)

  • $seq = Math::NumSeq::RadixConversion->new ()
  • $seq = Math::NumSeq::RadixConversion->new (from_radix => $r, to_radix => $t) β€” create and return a new sequence object. brand new baby sequence, born just for you πŸ’–

🧚 Random Access 🧚

  • $value = $seq->ith($i) β€” return $i as digits of base radix encoded in to_radix.
  • $bool = $seq->pred($value) β€” return true if $value occurs in the sequence. (does it slay? does it belong? vibe check βœ…)

if to_radix <= from_radix then all integer $value occurs. if to_radix > from_radix then $value written in to_radix must use only digits 0 to from_radix - 1 inclusive. no sneaky extra digits allowed bestie, them's the rules 🚫


πŸ‘‘ SEE ALSO πŸ‘‘

Math::NumSeq, Math::NumSeq::DigitSum, Math::NumSeq::HarshadNumbers


🌈 HOME PAGE 🌈

<http://user42.tuxfamily.org/math-numseq/index.html>


πŸŽ€ LICENSE πŸŽ€

Copyright 2012, 2013, 2014, 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.

ok important, no cap: there's no warranty, like at all, so don't come for anybody if it breaks πŸ™ˆ

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, bestie β€” brought to you by perl v5.42.0 on 2025-07-25, straight from the Math::N...nversion(3) files πŸ’–βœ¨ periodt.

πŸ“¦ where this page comes from