Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
$5 difference due to rounding?
Message
From
14/11/2006 17:31:08
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01169448
Message ID:
01169673
Views:
17
This message has been marked as a message which has helped to the initial question of the thread.
>>Naomi,
>>
>>I messed with the original message but it is interesting-
>>
>>
>>
>>? 24.93*.33
>>
>>? 24.93 *33/100 &&same result, right?
>>
>>
>>
>>Try this:
>>
>>
>>CREATE CURSOR cc (p1 n(11,2),p2 Y)
>>
>>lntotal=0
>>lyTotal=$0
>>
>>FOR lncounter = 1000 TO 20000 STEP 99
>>	lnNewval=lncounter/3
>>	insert into cc values (lnNewval,lnNewval)
>>	lntotal=lntotal+lnNewval
>>	lytotal=lyTotal+lnNewval
>>ENDFOR
>>
>>SUM p1 TO lnP1
>>SUM p2 TO lnP2
>>
>>?lntotal,lnp1
>>?lyTotal,lnp2
>>
>
>Interesting. So, does it mean I should use 11,2 (0r 9,2) in order to match exactly with my apparently not precise original calculation?

No, the sum has the same result.
The example is not correct because compare an (implicit) rounded sum with an not rounded sum
CLEAR
CREATE CURSOR cc (p1 n(11,4),p2 Y)

lntotal=0.0000
lyTotal=$0

FOR lncounter = 1000 TO 20000 STEP 99
	lnNewval=lncounter/3
	insert into cc values (lnNewval,lnNewval)	&& implicit round(,4) round(,4)
	lntotal=lntotal+round(lnNewval,4)
	lytotal=lyTotal+lnNewval	&& implicit round(,4)
ENDFOR

SUM p1 TO lnP1
SUM p2 TO lnP2

?lntotal,lnp1
?lyTotal,lnp2
I'll try this and see, if it makes a difference.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform