Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Get decimal portion
Message
De
14/05/2007 10:56:45
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
 
À
13/05/2007 16:21:08
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 7 SP1
Divers
Thread ID:
01225039
Message ID:
01225249
Vues:
23
>>>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.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform