Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Minus Zero
Message
De
04/02/2005 16:38:11
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Divers
Thread ID:
00983821
Message ID:
00984036
Vues:
13
>Thanks Fabio I'll keep that in Mind, May be I need to switch from
>ROUND(numb,2)
>
>To STR(numb1,19,2) = STR(numb2,19,2)

This don't change the issue,
STR uses round for compute the decimals part:
#DEFINE 	_DECIMALS 		5
#DEFINE		_ERRORPOWER		8
#DEFINE		_CICLES			50000

CLEAR
? "Expected fails:",INT(10^(_DECIMALS-_ERRORPOWER)/4*_CICLES)
t=0
FOR K=1 TO _CICLES
	X=RAND()*1000
    E=(RAND()-0.5)*1E-_ERRORPOWER
    IF ROUND(m.x,_DECIMALS) # ROUND(m.x+m.E,_DECIMALS)
      t=t+1
    ENDIF 
NEXT
?? "     fails: ",T

? "Expected fails:",INT(10^(_DECIMALS-_ERRORPOWER)/4*_CICLES)
t=0
FOR K=1 TO _CICLES
	X=RAND()*1000
    E=(RAND()-0.5)*1E-_ERRORPOWER
    IF STR(m.x,18,_DECIMALS) # STR(m.x+m.E,18,_DECIMALS)
      t=t+1
    ENDIF 
NEXT
?? "     fails: ",T
Another point, 19 in STR() is useless,
18 is sufficient ( 15,95 digits are used )

STR cannot to be used with a unbound currency:
x=$99999999999999.9900
? x,STR(x,19,2)
Fabio
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform