Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Best Material for Floors:

by TedYoung (Deacon)
on Dec 01, 2007 at 05:27 UTC ( #654278=note: print w/ replies, xml ) Need Help??


in reply to Best Material for Floors:

Come on everyone, why use something so complicated. If you need floor just use POSIX! It comes standard with all perls (I think).

Ted Young

($$<<$$=>$$<=>$$<=$$>>$$) always returns 1. :-)


Comment on Re: Best Material for Floors:
Select or Download Code
Re^2: Best Material for Floors: (POSIX--)
by tye (Cardinal) on Dec 01, 2007 at 05:32 UTC

    Bleh. POSIX::floor() on a Perl that uses "long double" (or similar) as NVs induces a great reduction in precision. Much better to just use:

    sub floor { $_[0] < 0 ? -int(-$_[0]) : int($_[0]); }
    sub floor { my $i= int( my $f= shift @_ ); return $i - ( $f<0 && $f!=$ +i ); }

    Now you know. :)

    - tye        

      floor -2.5 Should return -3.

        Heh, thanks. Fixed. Since I discovered the problem working with really large numbers, even my previous version was tons more accurate than POSIX::floor in that particular situation so it fixed the problem. That's how bad POSIX::floor can be.

        - tye        

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (14)
As of 2014-07-30 07:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (229 votes), past polls