Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^5: Portability of floor(log(N))

by toolic (Bishop)
on Mar 14, 2018 at 17:31 UTC ( #1210898=note: print w/replies, xml ) Need Help??


in reply to Re^4: Portability of floor(log(N))
in thread Portability of floor(log(N))

Using POSIX::log10() looks like the simplest solution. I will attempt to pester the tester with a modified version of FormatEng.pm.

Do you think I can simplify it by replacing POSIX::log10(1000) with 3, or will it be better to keep your code as-is?

my $e = floor( POSIX::log10($num) / 3 );

Replies are listed 'Best First'.
Re^6: Portability of floor(log(N))
by pryrt (Monsignor) on Mar 14, 2018 at 18:22 UTC

    log10(1000) will never change, and is exactly 3, so there's no reason not to use it

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1210898]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2020-10-30 19:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (284 votes). Check out past polls.

    Notices?