Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
ISSUE: SET DECIMAL and comparison
Message
De
19/04/2005 09:37:47
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Problèmes
Versions des environnements
Visual FoxPro:
VFP 9
Divers
Thread ID:
01005982
Message ID:
01006153
Vues:
21
Hi Sergey,
this explain the VFP rules:
SET DECIMALS TO 6

clear
x=9999999999.9
xInteger=9999999999
xFraction=0.9
Zero = 0
* ? , CAST and PADX() use the variable decimal for do the string conversion
? CAST(x AS v(20))
? CAST(xInteger AS V(20))
? CAST(xFraction AS V(20))
? 
? "when VFP compute a SUM expression, the rule is not immediate"
? "DEFINE VFPDECIMALS(exp_MemberList)"
? "  retDecimals=0"
? " FOR EACH exp IN exp_MemberList"
? "   retDecimals=ICASE(;"
? "     , exp is a literal numeric or a variable" && Atom
? "     ,    MAX(retDecimals,DECIMALS(exp))"
? "     , exp is a full literal exp"              && Not Atom
? "     ,    MAX(retDecimals,DECIMALS(exp),VFPDECIMALS(GETMEMBERS(exp)))"
? "    ,"                                         && not Atom
? "          MAX(retDecimals,VFPDECIMALS(GETMEMBERS(exp)))"
? "   )"
? "  ENDFOR"
? "  RETURN retDecimals"

? "EXAMPLES"

? "1=VFPDECIMALS([m.x],[9999999999])" at 5
? m.x - 9999999999
? "1=VFPDECIMALS([m.x],[9999999999.0])" at 5
? m.x- 9999999999.0
? "1=VFPDECIMALS([m.x],[(xInteger)])" at 5
? m.x-(xInteger)
? "1=VFPDECIMALS([m.x],[xInteger])" at 5
? m.x- xInteger

? "6=VFPDECIMALS([9999999999],[9999999999])" at 5
? 9999999999 - 9999999999  && this is equal to (9999999999 - 9999999999)
? "6=VFPDECIMALS([9999999999.9],[(9999999999)])" at 5
? 9999999999.9-(9999999999)
? "6=VFPDECIMALS([m.x],[(9999999999)])" at 5
? m.x-(9999999999)
? "6=VFPDECIMALS([m.x],[(0+9999999999)])" at 5   && this cut the rule
? m.x-(0+9999999999)
? "1=VFPDECIMALS([m.x],[(m.zero+9999999999)])" at 5  && this cut the cut rule
? m.x-(m.zero+9999999999)
Someone can call this By design, but it is a crazy design,
and you known as I define a "Crazy design" : only a little word, beginning with "B"

Fabio
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform