Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
A big problem: how I can compute sum and round result
Message
From
15/11/2003 13:29:06
 
 
To
15/11/2003 12:12:31
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00850264
Message ID:
00850289
Views:
21
Add more variability.

All is possible.
SET DECIMALS TO 11
SET FIXED ON
CREATE CURSOR orderRows (quantity N(10,1),weight N(9,2))
INSERT INTO orderRows VALUES (3.9,55.15)

scanTotalWeight=0
scan
scanTotalWeight=m.scanTotalWeight+quantity*weight
endscan

SUM quantity*weight					TO sumTotalWeight
CALCULATE SUM(quantity*weight)	TO calcTotalWeight

SELECT SUM(quantity*weight) totalweight FROM orderRows INTO ARRAY selTotalWeight
CLEAR
? 'Use SELECT SUM() like reference :', selTotalWeight ,STR(selTotalWeight ,10,2),ROUND(scanTotalWeight,2)
?
* scanTotalWeight IS = TO selTotalWeight, BUT have a internal difference
? 'sum with scan and variable ',scanTotalWeight,STR(scanTotalWeight,10,2),' round ',ROUND(scanTotalWeight,2)
?? ' equal ',scanTotalWeight=selTotalWeight,'diff ', (scanTotalWeight-selTotalWeight)*1024*1024*1024*1024*1024 
?
* sumTotalWeight IS <> TO selTotalWeight, BUT return equal STR(,,2) and different ROUND(,2), and have a internal difference
? 'sum with SUM ',sumTotalWeight ,STR(sumTotalWeight ,10,2),' round ',ROUND(sumTotalWeight ,2)
?? ' equal ',sumTotalWeight =selTotalWeight,'diff ', (sumTotalWeight -selTotalWeight)*1024*1024*1024*1024*1024 
?
* calcTotalWeight IS == TO sumTotalWeight 
? 'sum with CALCULATE ',calcTotalWeight,STR(calcTotalWeight,10,2),' round ',ROUND(calcTotalWeight,2)
?? ' equal ',calcTotalWeight=selTotalWeight,'diff ', (calcTotalWeight-selTotalWeight)*1024*1024*1024*1024*1024 
Fabio
Previous
Reply
Map
View

Click here to load this message in the networking platform