- SEE ALSO
Math::Utils::XS - Some math utility functions implemented in XS
use Math::Utils::XS q(utility); my $l10 = log10(100); # returns 2 my $l2 = log2(32); # returns 5 my $sum = fsum(1, 1e50, 1, -1e50); # returns 2 my $sign = sign(-22); # returns -1 my $sign = sign(3 - 3); # returns 0 my $sign = sign(+22); # returns +1 my $f = floor(22/7); # returns 3 my $f = floor(2.7182); # returns 2 my $c = floor(-22/7); # returns -4 my $c = floor(-2.7182); # returns -3
Note: functions marked with a (*) simply expose the corresponding function from the C library.
Compute a number's logarithm in base 10.
Compute a number's logarithm in base 2.
Compute the largest integer that is less than or equal than a number.
Compute the smallest integer that is greater than or equal than a number.
Return -1, 0 or +1 depending on whether a number is negative, zero or positive.
Compute the sum of all arguments. It will process each separate argument, and recurse into any arrays (but not hashes) all the way inside.
The sum is computed in a way that you can safely add floating point numbers, even if their magnitudes are very different. This is done using Neumaier's modification of Kahan's summation algorith, described here: https://en.wikipedia.org/wiki/Kahan_summation_algorithm.
Copyright (C) Gonzalo Diethelm.
This library is free software; you can redistribute it and/or modify it under the terms of the MIT license.
gonzus AT cpan DOT org