Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Round() Bug
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00459503
Message ID:
00459593
Vues:
19
Paul,

This is a follow up to my previous response. It turns out that both your solution and my suggestion suffer from the same problem when the issue Sergey pointed out (Q247494) gets involved. Here's the code:
FOR i = 1 TO 3 step .1
   debugout PaulRound(i, 15)
   debugout round( val( transform(i)), 15)
ENDFOR

FUNCTION PaulRound( tnNumber, tnDecimals)
RETURN round(val(alltrim(str(tnNumber,20,tnDecimals+1))),tndecimals)
At 1.6 both start returning 1.600000000000001, 1.700000000000001, etc. At 2.7 the error moves to 2.700000000000002, 2.800000000000002, etc. Moreover, TRANSFORM itself is not the problem, since using
round( val( alltrim( str( i, 17, 15))), 15)
instead of TRANSFORM gives the same error.

This needs some more study, IMO.
Rick Borup, MCSD

recursion (rE-kur'-shun) n.
  see recursion.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform