.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Math::PlanePath::Base::Digits 3pm" .TH Math::PlanePath::Base::Digits 3pm "2021-01-23" "perl v5.32.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Math::PlanePath::Base::Digits \-\- helpers for digit based paths .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 3 \& use Math::PlanePath::Base::Digits \*(Aqdigit_split_lowtohigh\*(Aq; \& foreach my $digit (digit_split_lowtohigh ($n, 16)) { \& } .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This is a few generic helper functions for paths based on digits or powering. .PP They're designed to work on plain Perl integers and floats and there's some special case support for \f(CW\*(C`Math::BigInt\*(C'\fR. .SH "EXPORTS" .IX Header "EXPORTS" Nothing is exported by default but each function below can be as in the usual Exporter style, .PP .Vb 1 \& use Math::PlanePath::Base::Digits \*(Aqround_down_pow\*(Aq; .Ve .PP (But not \f(CW\*(C`parameter_info_radix2()\*(C'\fR, for the reason described below.) .SH "FUNCTIONS" .IX Header "FUNCTIONS" .SS "Generic" .IX Subsection "Generic" .ie n .IP """($power, $exponent) = round_up_pow ($n, $radix)""" 4 .el .IP "\f(CW($power, $exponent) = round_up_pow ($n, $radix)\fR" 4 .IX Item "($power, $exponent) = round_up_pow ($n, $radix)" .PD 0 .ie n .IP """($power, $exponent) = round_down_pow ($n, $radix)""" 4 .el .IP "\f(CW($power, $exponent) = round_down_pow ($n, $radix)\fR" 4 .IX Item "($power, $exponent) = round_down_pow ($n, $radix)" .PD Return the power of \f(CW$radix\fR equal to or either higher or lower than \f(CW$n\fR. For example .Sp .Vb 4 \& ($pow, $exp) = round_down_pow (260, 2); \& # $pow==512 # the next higher power \& # $exp==9 # the exponent in that power \& # 2**9=512 is next above 260 \& \& ($pow, $exp) = round_down_pow (260, 2); \& # $pow==256 # the next lower power \& # $exp==8 # the exponent in that power \& # 2**8=256 is next below 260 .Ve .ie n .IP """@digits = digit_split_lowtohigh ($n, $radix)""" 4 .el .IP "\f(CW@digits = digit_split_lowtohigh ($n, $radix)\fR" 4 .IX Item "@digits = digit_split_lowtohigh ($n, $radix)" .PD 0 .ie n .IP """@bits = bit_split_lowtohigh ($n)""" 4 .el .IP "\f(CW@bits = bit_split_lowtohigh ($n)\fR" 4 .IX Item "@bits = bit_split_lowtohigh ($n)" .PD Return a list of digits from \f(CW$n\fR in base \f(CW$radix\fR, or in binary. For example, .Sp .Vb 2 \& @digits = digit_split_lowtohigh (12345, 10); \& # @digits = (5,4,3,2,1) # decimal digits low to high .Ve .Sp If \f(CW\*(C`$n==0\*(C'\fR then the return is an empty list. The current code expects \f(CW\*(C`$n >= 0\*(C'\fR. .Sp \&\*(L"lowtohigh\*(R" in the name tries to make it clear which way the digits are returned. \f(CW\*(C`reverse()\*(C'\fR can be used to get high to low instead (see \&\*(L"reverse\*(R" in perlfunc). .Sp \&\f(CW\*(C`bit_split_lowtohigh()\*(C'\fR is the same as \f(CW\*(C`digit_split_lowtohigh()\*(C'\fR called with radix=2. .ie n .IP """$n = digit_join_lowtohigh ($arrayref, $radix)""" 4 .el .IP "\f(CW$n = digit_join_lowtohigh ($arrayref, $radix)\fR" 4 .IX Item "$n = digit_join_lowtohigh ($arrayref, $radix)" .PD 0 .ie n .IP """$n = digit_join_lowtohigh ($arrayref, $radix, $zero)""" 4 .el .IP "\f(CW$n = digit_join_lowtohigh ($arrayref, $radix, $zero)\fR" 4 .IX Item "$n = digit_join_lowtohigh ($arrayref, $radix, $zero)" .PD Return a value made by joining digits from \f(CW$arrayref\fR in base \f(CW$radix\fR. For example, .Sp .Vb 3 \& @digits = (5,4,3,2,1) # decimal digits low to high \& $n = digit_split_lowtohigh (\e@digits, 10); \& # $n == 12345 .Ve .Sp Optional \f(CW$zero\fR can be a 0 of an overloaded number type such as \&\f(CW\*(C`Math::BigInt\*(C'\fR to give a returned \f(CW$n\fR of that type. .SS "Subclassing" .IX Subsection "Subclassing" .ie n .IP """$aref = parameter_info_array()""" 4 .el .IP "\f(CW$aref = parameter_info_array()\fR" 4 .IX Item "$aref = parameter_info_array()" Return an arrayref of a \f(CW\*(C`radix\*(C'\fR parameter, default 2. This is designed to be imported into a PlanePath subclass as its \f(CW\*(C`parameter_info_array()\*(C'\fR method. .Sp .Vb 2 \& package Math::PlanePath::MySubclass; \& use Math::PlanePath::Base::Digits \*(Aqparameter_info_array\*(Aq; .Ve .Sp The arrayref is .Sp .Vb 10 \& [ { name => \*(Aqradix\*(Aq, \& share_key => \*(Aqradix_2\*(Aq, \& display => \*(AqRadix\*(Aq, \& type => \*(Aqinteger\*(Aq, \& minimum => 2, \& default => 2, \& width => 3, \& description => \*(AqRadix (number base).\*(Aq, \& } \& ] .Ve .ie n .IP """$href = Math::PlanePath::Base::Digits::parameter_info_radix2()""" 4 .el .IP "\f(CW$href = Math::PlanePath::Base::Digits::parameter_info_radix2()\fR" 4 .IX Item "$href = Math::PlanePath::Base::Digits::parameter_info_radix2()" Return the single \f(CW\*(C`radix\*(C'\fR parameter hashref from the info above. This can be used when a subclass wants the radix parameter and other parameters too, .Sp .Vb 9 \& package Math::PlanePath::MySubclass; \& use constant parameter_info_array => \& [ \& { name => \*(Aqsomething_else\*(Aq, \& type => \*(Aqinteger\*(Aq, \& default => \*(Aq123\*(Aq, \& }, \& Math::PlanePath::Base::Digits::parameter_info_radix2(), \& ]; .Ve .Sp If the \*(L"description\*(R" part should be more specific or more detailed then it could be overridden with for example .Sp .Vb 3 \& { %{Math::PlanePath::Base::Digits::parameter_info_radix2()}, \& description => \*(AqRadix, for both something and something.\*(Aq, \& }, .Ve .Sp This function is not exportable since it's meant for a one-off call in an initializer and so no need to import it for repeated use. .SH "SEE ALSO" .IX Header "SEE ALSO" Math::PlanePath, Math::PlanePath::Base::Generic .PP Math::BigInt .SH "HOME PAGE" .IX Header "HOME PAGE" .SH "LICENSE" .IX Header "LICENSE" Copyright 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Kevin Ryde .PP This file is part of Math-PlanePath. .PP Math-PlanePath is free software; you can redistribute it and/or modify it under the terms of the \s-1GNU\s0 General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. .PP Math-PlanePath is distributed in the hope that it will be useful, but \&\s-1WITHOUT ANY WARRANTY\s0; without even the implied warranty of \s-1MERCHANTABILITY\s0 or \s-1FITNESS FOR A PARTICULAR PURPOSE.\s0 See the \s-1GNU\s0 General Public License for more details. .PP You should have received a copy of the \s-1GNU\s0 General Public License along with Math-PlanePath. If not, see .