in reply to Clean log_10 ?

C:\Users\Peter>perl -MPOSIX=log10 -le "$,=', ';print $_, int($_) for l +og(1e12)/log(10), log10(1e12)" 12, 11 12, 12

log() is implemented as precisely as possible for base e; unfortunately, dividing one log-base-e by another is not always as precise as you want; OTOH, using POSIX::log10, you get the function implemented as precisely as possible for base 10, which appears to be what you want.

Replies are listed 'Best First'.
Re^2: Clean log_10 ?
by LanX (Saint) on Nov 28, 2019 at 17:04 UTC
    Thanks I went directly to POSIX#MATH and only saw constants and missed the function log10.

    This seems to work reasonably well up to 1e308! :)

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery FootballPerl is like chess, only without the dice