Rounding digits

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Brian
    Senior Member
    • Apr 2000
    • 252

    Rounding digits

    How can I take a number like say 100.3333444 and round that off to 2 digits so it would output say 100.33 instead.

    Thanks in advanced

    -Brian
    << This Space Intentionally Left Blank >>
  • Mark Hensler
    Senior Member
    • Feb 2001
    • 570

    #2
    number_format()

    Comment

    • Freddie Bingham
      Former vBulletin Developer
      • May 2000
      • 14057
      • 1.1.x

      #3
      and sprintf (my preference)

      Comment

      • Brian
        Senior Member
        • Apr 2000
        • 252

        #4
        Thanks guys unfortunately my php knowledge is slim at best and I cant figure out how to use these

        Here is the part of code I need it for:

        <? echo $totalvalue; ?>

        So basically that value which is printed out (say it would be 141.55221) I would need to be formated to 2 decimal places to say 141.55.

        Can you tell me how to do that code wise (sorry for the dumb question I am sloooowly learning lol)

        -Brian
        << This Space Intentionally Left Blank >>

        Comment

        • Freddie Bingham
          Former vBulletin Developer
          • May 2000
          • 14057
          • 1.1.x

          #5
          echo sprintf('%.2f', $totalvalue);

          Comment

          • Brian
            Senior Member
            • Apr 2000
            • 252

            #6
            Thanks!!

            -Brian
            << This Space Intentionally Left Blank >>

            Comment

            widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
            Working...