Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Making sure of 2 decimal places?
Message
From
27/03/1998 10:19:29
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
26/03/1998 20:43:04
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00087255
Message ID:
00087668
Views:
34
>>>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
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform