++ed by:

1 non-PAUSE user.

Gonzalo Diethelm
and 1 contributors

NAME

Math::Utils::XS - Some math utility functions implemented in XS

VERSION

Version 0.000002

SYNOPSIS

    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

DESCRIPTION

FUNCTIONS

log10

Compute a number's logarithm in base 10.

log2

Compute a number's logarithm in base 2.

sign

Return -1, 0 or +1 depending on whether a number is negative, zero or positive.

floor

Compute the largest integer that is less than or equal than a number.

ceil

Compute the smallest integer that is greater than or equal than a number.

fsum

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.

SEE ALSO

https://metacpan.org/pod/Math::Utils

LICENSE

Copyright (C) Gonzalo Diethelm.

This library is free software; you can redistribute it and/or modify it under the terms of the MIT license.

AUTHOR

  • Gonzalo Diethelm gonzus AT cpan DOT org

THANKS