Displaying float with only 2 decimal places?

Discussion in 'iOS Programming' started by Jeremy1026, Sep 3, 2008.

  1. macrumors 68000

    Joined:
    Nov 3, 2007
    #1
    Is it possible to display a float variable only out to the 2nd decimal place (hundredths place)?
     
  2. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
  3. thread starter macrumors 68000

    Joined:
    Nov 3, 2007
    #3
    Thanks for your help.

    Incase anyone else finds this in a search, the way to do it is to use %.2f in the stringWithFormat: method.
     
  4. macrumors member

    Joined:
    Jul 18, 2008
    Location:
    Chicago-area
    #4

Share This Page