Professional Web Applications Themes

Rounding off - PERL Beginners

Hello, I need the ability to round off dollar amounts to the nearest 100th of a dollar amount, IE $14.9564 to $14.96 or $132.1123 to $113.11 what is the best way to accomplish this ?? TIA -- Mike<mickalo>Blezien =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Thunder Rain Internet Publishing Providing Internet Solutions that work! [url]http://www.thunder-rain.com[/url] Quality Web Hosting [url]http://www.justlightening.net[/url] MSN: [email]mickalothunder-rain.com[/email] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=...

  1. #1

    Default Rounding off

    Hello,

    I need the ability to round off dollar amounts to the
    nearest 100th of a dollar amount, IE $14.9564 to $14.96 or
    $132.1123 to $113.11

    what is the best way to accomplish this ??

    TIA
    --
    Mike<mickalo>Blezien
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    Thunder Rain Internet Publishing
    Providing Internet Solutions that work!
    [url]http://www.thunder-rain.com[/url]
    Quality Web Hosting
    [url]http://www.justlightening.net[/url]
    MSN: [email]mickalothunder-rain.com[/email]
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

    Mike Blezien Guest

  2. #2

    Default Re: Rounding off

    --As off Saturday, November 22, 2003 4:27 PM -0600, Mike Blezien is
    alleged to have said:
    > Hello,
    >
    > I need the ability to round off dollar amounts to the nearest 100th
    > of a dollar amount, IE $14.9564 to $14.96 or $132.1123 to $113.11
    >
    > what is the best way to accomplish this ??
    --As for the rest, it is mine.

    Best way? Well, that depends...

    A simple sprintf("%.2f", $num) will do initial rounding, but read
    'perldoc -f round' for issues.

    Slightly more flexible (and possibly more precise) is Math::Round,
    which can handle rounding in several different formats.

    The question is, how precise do those numbers need to be? For a real
    financial application you probably need to write your own rounding
    routine, to be sure it acts exactly as you need it. If you just need
    to print out a few dollar figures, either of the above will probably
    do.

    Daniel T. Staal

    ---------------------------------------------------------------
    This email copyright the author. Unless otherwise noted, you
    are expressly allowed to retransmit, quote, or otherwise use
    the contents for non-commercial purposes. This copyright will
    expire 5 years after the author's death, or in 30 years,
    whichever is longer, unless such a period is in excess of
    local copyright law.
    ---------------------------------------------------------------
    Daniel Staal Guest

Similar Threads

  1. Rounding to nearest 100
    By ccnorris in forum Coldfusion - Advanced Techniques
    Replies: 4
    Last Post: May 30th, 11:44 PM
  2. Rounding Up
    By Brent Bortnick in forum ASP
    Replies: 14
    Last Post: October 8th, 04:19 AM
  3. how to keep decimals from rounding
    By Rob Yelvington in forum PHP Development
    Replies: 3
    Last Post: August 26th, 04:58 PM
  4. [PHP] Rounding issue
    By Larry E . Ullman in forum PHP Development
    Replies: 3
    Last Post: July 29th, 10:21 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139