Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
On VFP 4000 sums are not reliable!
Message
De
16/12/2005 06:10:53
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
On VFP 4000 sums are not reliable!
Versions des environnements
Visual FoxPro:
VFP 9
Database:
Visual FoxPro
Divers
Thread ID:
01078586
Message ID:
01078586
Vues:
49
this is not a bug, but a VFP feature by design
CLEAR 
CLOSE TABLES ALL

CREATE CURSOR table1 (id I, coeff1 I)
INSERT INTO table1 VALUES (0,32767)
INSERT INTO table1 VALUES (1,32767)

CREATE CURSOR TEST (fk I,n N(9,6))

FOR K=1 TO 4000
	INSERT INTO TEST VALUES (m.k%2,0.100000)
NEXT

SELECT	SUM(n*coeff1) VFP,'13106800,000000' Exact FROM test JOIN TABLE1 ON FK=ID

* of course ROUND() is useless
SELECT	ROUND(SUM(ROUND(ROUND(n,6)*ROUND(coeff1,6),6)),6) VFP,'13106800,000000' Exact FROM test JOIN TABLE1 ON FK=ID
this is a simple example, but it is possible to build a combination of numbers
what it produces smaller values but however wrong.

A workaround exists, but it is orrible
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform