In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] wrote:
>My question is, how can I implement some code into the above, so that when the 
>two print statements run, it rounds up any such 100.5,10.6 code to normal 
>101,11.

This is actually documented in the Perl FAQ, as found in "man perlfaq"
or at various places on the web.  Section 4 ("man perlfaq4") answers
this very question:

       Does perl have a round function?  What about ceil() and
       floor()? Trig functions?

       For rounding to a certain number of digits, sprintf() or
       printf() is usually the easiest route.

       The POSIX module (part of the standard perl distribution)
       implements ceil(), floor(), and a number of other
       mathematical and trigonometric functions.

       In 5.000 to 5.003 Perls, trigonometry was done in the
       Math::Complex module.  With 5.004, the Math::Trig module
       (part of the standard perl distribution) implements the
       trigonometric functions. Internally it uses the
       Math::Complex module and some functions can break out from
       the real axis into the complex plane, for example the
       inverse sine of 2.

       Rounding in financial applications can have serious
       implications, and the rounding method used should be
       specified precisely.  In these cases, it probably pays not
       to trust whichever system rounding is being used by Perl,
       but to instead implement the rounding function you need
       yourself.


K.

-- 
Kirrily Robert -- <[EMAIL PROTECTED]> -- http://netizen.com.au/
Internet and Open Source Development, Consulting and Training
Level 13, 500 Collins St, Melbourne VIC 3000
Phone: +61 3 9614 0949  Fax +61 3 9614 0948
--
SLUG - Sydney Linux Users Group Mailing List - http://www.slug.org.au
To unsubscribe send email to [EMAIL PROTECTED] with
unsubscribe in the text

Reply via email to