Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Get decimal portion
Message
From
14/05/2007 10:56:45
Dragan Nedeljkovich
Now officially retired
Zrenjanin, Serbia
 
 
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 7 SP1
Miscellaneous
Thread ID:
01225039
Message ID:
01225249
Views:
35
>>>Reza,
>>>
>>>Try:
>>>? 987.230%1
>>>? Mod(987.230,1)
>>
>>Though for negative numbers it won't return the value one would expect. The % operator will return the distance between the next integer on the left of the number and the number itself... so while the decimals for -8.133 may be 0.133, -8.133%1 will be 0.867.
>
>Ín that case, how about how I would solve it (from the head, without testing):
>
>x = 987.230
>y = ( x - int( x ) ) * 100
>
>OTOH, one might also consider: mod( abs( x ), 1 ) * 100

Actually, without multiplication with 100 - abs(x)%1 or mod(abs(x),1) is the way. The question was to get the decimal part, which is supposedly between 0 and 0.999999. Though for decimal numbers I wonder whether it would be between 0 and 0.999999 or between -1 and -0.00000...0001.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Reply
Map
View

Click here to load this message in the networking platform