Trim trailing 0 from decimal place of number

Discussion in 'ASP .Net' started by martin, Jul 19, 2004.

  1. martin

    martin Guest

    Hi,

    I am having difficulty trimming any traling 0's from my decimal numbers.
    I store then in the database to 2 decimal places.
    This means that when they come back to my application they still diply with
    all the decimal places

    eg

    10.00 displays as 10.00
    10.10 displays as 10.10

    what I would like to achieve is the following

    10.00 displays as 10
    10.10 displays as 10.1

    many thanks in advance

    cheers

    martin.
     
    martin, Jul 19, 2004
    #1
    1. Advertising

  2. string.Format("{0}",10);
    string.Format("{0}",10.10);

    should do the trick. Actually the above behavior should be the default
    behavior...

    +++ Rick ---

    --

    Rick Strahl
    West Wind Technologies
    http://www.west-wind.com/
    http://www.west-wind.com/weblog/
    ----------------------------------
    Making waves on the Web


    "martin" <> wrote in message
    news:...
    > Hi,
    >
    > I am having difficulty trimming any traling 0's from my decimal numbers.
    > I store then in the database to 2 decimal places.
    > This means that when they come back to my application they still diply

    with
    > all the decimal places
    >
    > eg
    >
    > 10.00 displays as 10.00
    > 10.10 displays as 10.10
    >
    > what I would like to achieve is the following
    >
    > 10.00 displays as 10
    > 10.10 displays as 10.1
    >
    > many thanks in advance
    >
    > cheers
    >
    > martin.
    >
    >
     
    Rick Strahl [MVP], Jul 19, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Konstantinos Pachopoulos

    trim start and trailing space chars from string

    Konstantinos Pachopoulos, Sep 15, 2007, in forum: Python
    Replies:
    1
    Views:
    454
    John Machin
    Sep 15, 2007
  2. John B. Matthews
    Replies:
    4
    Views:
    671
    John B. Matthews
    Sep 12, 2008
  3. Roedy Green
    Replies:
    3
    Views:
    627
  4. FAQ server
    Replies:
    0
    Views:
    145
    FAQ server
    Aug 29, 2006
  5. FAQ server
    Replies:
    0
    Views:
    142
    FAQ server
    Oct 26, 2006
Loading...

Share This Page