Professional Web Applications Themes

Changing numbers - PHP Development

I have the following numbers: 12.400 666.75 23 369.2 3.234 How can I make them have at least 2 decimal places? So, they will output: 12.40 666.75 23.00 269.20 3.234 Thanks in advance! -- - Zavaboy [email]zavaboyhotmail.com[/email] [url]www.zavaboy.com[/url]...

  1. #1

    Default Changing numbers

    I have the following numbers:

    12.400
    666.75
    23
    369.2
    3.234

    How can I make them have at least 2 decimal places?
    So, they will output:

    12.40
    666.75
    23.00
    269.20
    3.234

    Thanks in advance!

    --

    - Zavaboy
    [email]zavaboyhotmail.com[/email]
    [url]www.zavaboy.com[/url]


    Zavaboy Guest

  2. #2

    Default Re: [PHP] Changing numbers

    * Thus wrote zavaboy (zavaboyhotmail.com):
    > I have the following numbers:
    >
    > 12.400
    > 666.75
    > 23
    > 369.2
    > 3.234
    >
    > How can I make them have at least 2 decimal places?
    > So, they will output:
    >
    > 12.40
    > 666.75
    > 23.00
    > 269.20
    > 3.234
    >
    > Thanks in advance!
    [url]http://php.net/number_format[/url]
    or
    [url]http://php.net/printf[/url]



    Curt
    --
    "I used to think I was indecisive, but now I'm not so sure."
    Curt Zirzow Guest

  3. #3

    Default Re: [PHP] Changing numbers

    Curt Zirzow wrote:
    >* Thus wrote zavaboy (zavaboyhotmail.com):
    >
    >
    >>I have the following numbers:
    >>
    >>12.400
    >>666.75
    >>23
    >>369.2
    >>3.234
    >>
    >>How can I make them have at least 2 decimal places?
    >>So, they will output:
    >>
    >>12.40
    >>666.75
    >>23.00
    >>269.20
    >>3.234
    >>
    >>Thanks in advance!
    >>
    What I dont understand is that your examples are not consitant. You
    want 2 or more decimal positions, so as if there are more than 2, to
    leave what exists. But your first example, you truncate the last 0. Is
    that a typo, or intentional?

    Justin Gruenberg Guest

  4. #4

    Default RE: [PHP] Changing numbers

    > From: justin gruenberg [mailto:justinice.kewlio.net]
    > Subject: Re: [PHP] Changing numbers
    >
    >
    > Curt Zirzow wrote:
    >
    > >* Thus wrote zavaboy (zavaboyhotmail.com):
    > >
    > >
    > >>I have the following numbers:
    > >>
    > >>12.400
    > >>666.75
    > >>23
    > >>369.2
    > >>3.234
    > >>
    > >>How can I make them have at least 2 decimal places?
    > >>So, they will output:
    > >>
    > >>12.40
    > >>666.75
    > >>23.00
    > >>269.20
    > >>3.234
    > >>
    > >>Thanks in advance!
    > >>
    >
    > What I dont understand is that your examples are not consitant. You
    > want 2 or more decimal positions, so as if there are more than 2, to
    > leave what exists. But your first example, you truncate the
    > last 0. Is
    > that a typo, or intentional?
    What's so hard about this?

    He wants two or more *significant* positions preserved. Show to at least
    two decimal places, trailing zeroes truncated beyond the 2nd decimal place.

    Roger B.A Klorese Guest

  5. #5

    Default Re: [PHP] Changing numbers

    Roger B.A Klorese wrote:
    >>>* Thus wrote zavaboy (zavaboyhotmail.com):
    >>>
    >>>
    >>>
    >>>>I have the following numbers:
    >>>>
    >>>>12.400
    >>>>666.75
    >>>>23
    >>>>369.2
    >>>>3.234
    >>>>
    >>>>How can I make them have at least 2 decimal places?
    >>>>So, they will output:
    >>>>
    >>>>12.40
    >>>>666.75
    >>>>23.00
    >>>>269.20
    >>>>3.234
    >
    > What's so hard about this?
    >
    > He wants two or more *significant* positions preserved. Show to at least
    > two decimal places, trailing zeroes truncated beyond the 2nd decimal place.
    I am not sure what he is after, but I don't think it has to do with
    significant figures (if that is what you meant). If that was the case,
    12.400 should remain 12.400. Trailing zeros to the right of a decimal
    are significant.

    - Brad


    Brad Pauly Guest

  6. #6

    Default RE: [PHP] Changing numbers

    > From: Brad Pauly [mailto:bradrobinsontech.com]
    > Sent: Monday, July 21, 2003 2:45 PM
    > To: Roger B.A Klorese
    > Cc: 'justin gruenberg'; 'Curt Zirzow'; 'PHP-General'
    > Subject: Re: [PHP] Changing numbers
    >
    >
    > I am not sure what he is after, but I don't think it has to do with
    > significant figures (if that is what you meant). If that was
    > the case,
    > 12.400 should remain 12.400. Trailing zeros to the right of a decimal
    > are significant.
    Perhaps. But he's saying that, for his purposes, they're not -- if anything
    to the right of the last shown zero existed, it would be reflected in the
    output.

    Roger B.A Klorese Guest

Similar Threads

  1. Changing text without changing frames.
    By Jose Olivas in forum Macromedia Flash
    Replies: 1
    Last Post: March 21st, 11:36 AM
  2. [PHP] Changing numbers
    By Zavaboy in forum PHP Development
    Replies: 6
    Last Post: July 21st, 06:54 PM
  3. IP numbers
    By Val in forum Windows Setup, Administration & Security
    Replies: 2
    Last Post: July 11th, 04:12 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