NAME
Math::Simple - Very simple, commonly used math routines
VERSION
Version "2.0.0"
SYNOPSIS
use Math::Simple qw(logb log2);
my $low = min($a,$b, $c, $d ...); # least positive num
my $hi = max($a,$b); # most positive num
my $digits_ƒ = sub ($) {int log10($_[0]); # log10 default export
my $log_in_base = logb($base,$num); # log arbitrary base
my $log16_ƒ = logb(16); # create log16 func
my $bits_needed_ƒ = sub ($) {int log2($_[0])};
use constant mbits => log2(~1); # compile constant
DESCRIPTION
Very simple math routines that I end up re-using in many progs and libified for easy access.
Currently five function, three exported by default. Default exports are min(), max() and log10(). Optional exports are log2
and logb
. Note on <logb>: it returns a log in any base, with the base as the first param, and number as the 2nd param, but given 1 parameter (the base), it will return a function ref that only returns that base.
Math::Simple uses Xporter, so including logb
or log2
doesn't break the defaults import list see Xporter.