Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Making sure of 2 decimal places?
Message
De
27/03/1998 21:05:02
 
 
À
27/03/1998 10:19:29
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00087255
Message ID:
00087865
Vues:
41
>>>>What is the easiest way to determine if a number has two decimal places and if not, append it so it will have two?
>>>
>>>nNumber = (nNumber-int(nNumber))*100
>>>if nNumber > 9
>>> return .t.
>>>endif
>>>
>>>Cetin
>>
>>Snip.... (But I donno what means!)
>>Seem wrong. if nNumber is 5.01 !!
>>or typing error.
>>
>>[if nNumber > 0 ]....
>>I perfer to use [if Empty(nNumber)]
>>
>>Well, I think it would be:
>>
>>Alltrim(Str(nNumber, 10,2))
>>
>>Make to 2 decimal string without test because cannot make 5.00 as requiry!!
>>If you want to make 5.001 to 5.01, it would be:
>>
>>Alltrim(Str(Ceiling(100*nNumber)/100, 10,2))
>>
>>It will be very useful on report and label printing!! ^_^;
>Thanks Justok,
>Seems I got the question wrong. This one might be more true :
>
>* 5,5.0,5.00,5.0049 etc would be returned as 5.00
>return round(nNumber,2)
>
>Cetin

Well, Yesterday I wonder that it may more crazy on return:

Alltrim(Str(Ceiling(100*nNumber)/100, 10,2))

e.g. 5.0000001 ==> 5.01

But it is for Price Value!! ;D===
The weak wait for chance, The strong bid for chance,
The clever notch up chance, but The merciful give you chance.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform