Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Rounding Numbers
Message
De
07/05/2008 11:19:17
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, États-Unis
 
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
VB 8.0
Divers
Thread ID:
01315443
Message ID:
01315622
Vues:
12
What if the number is 2.125? I believe that will truncate instead of round.

>Are you displaying the number as text? If so d.ToString("N2") or d.ToString("#0.00") should work.
>If you are doing math on the numbers then it doesn't matter if the number is 2 or 2.00.
>
>>Decimal.
>>
>>>What type is your number?
>>>
>>>>I can't seem to find a good method for rounding and padding numbers. For example:
>>>>
>>>>1 becomes 1.00
>>>>2 becomes 2.00
>>>>1.1 becomes 1.10
>>>>1.123 becomes 1.12
>>>>1.125 becomes 1.13
>>>>1.126 becomes 1.13
>>>>
>>>>
>>>>There has to be something built-in to do this, right? Currently I am manually parsing the digits and it's painful. Decimal.Round won't pad, so 1 will stay 1, and not become 1.00.
>>>>
>>>>Thanks!
Very fitting: http://xkcd.com/386/
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform