Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SET DECIMALS TO is used if SET FIXED is OFF ?
Message
De
21/11/2003 06:33:35
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00850956
Message ID:
00852251
Vues:
17
Hi Sergey

----------
If SET FIXED is OFF than for existing variables current SET DECIMALS setting is ignored because it's stored with the variable when it's created. The newly created variables shoud respect current SET DECIMALS setting.
---------

I unknown because you write this rule ( i have not found it on documentation )

I aspected a rule like
MAX(decNeedOnExpression,setDecimal)
OR
decNeedOnExpression.

Then i try to verify.

Run this example, and read result with attention
( i think you not waste your time )
SET FIXED OFF
SET TALK OFF
CLEAR

CREATE CURSOR orderRows (quantity N(10,1),weight N(12,6))

INSERT INTO orderRows VALUES (24,86.173125)

FOR nDec=0 TO 11 STEP 5
	? TRANSFORM(m.nDec,'@R -------- SET DECIMAL TO 99 ----------')

	SET DECIMALS TO m.nDec
	
	varDec1 = 3.1255
	varDec4 = 2.5567

	scanTotalWeight=0.0
	SCAN
		STORE m.scanTotalWeight+quantity*weight to scanTotalWeight
	ENDSCAN

	SELECT SUM(quantity*weight) totalweight FROM orderRows INTO array selTotalWeight

	SUM quantity*weight					TO sumTotalWeight
	CALCULATE SUM(quantity*weight)	TO calcTotalWeight	&& + RAPIDO

	? 'into variable   	', scanTotalWeight									&& i aspected 7 decimals
	? 'SELECT          	', selTotalWeight										&& i aspected 7 decimals
	? 'SUM             	', sumTotalWeight										&& i aspected 7 decimals
	? 'CALCULATE         ',calcTotalWeight										&& i aspected 7 decimals

	? 'literal product 		',3.1*2.5567										&& i aspected 4 decimals
	? 'literal division		',3.1/2.5567										&& i wish full decimals
	? 'variable division	',m.varDec1/m.varDec4							&& i wish full decimals
	? 'integer exponentation	',3.1^8											&& i wish 8 decimals
	? 'fractional exponentation ',3.1^2.5567									&& i wish full decimals
	? 'TRANSFORM INTEGER	',TRANSFORM(215.085*1000.0)						&& i aspected 4 decimals
	? 'TRANSFORM DECIMAL	',TRANSFORM(215.085*1001.0)						&& i aspected 4 decimals
	? 
	RELEASE varDec1,varDec4,zz
NEXT
?
? '******* Rule to compute decimal on result *******'
? 'into variable		decResult = MAX(decItems,decProduct)' 					&& correct
? 'SELECT		decResult = MAX(decExpItems,decProducts)' 					&& correct 
? 'SUM			decResult = MAX(decItems,decProducts,setDecimal)'			&& incorrect
? 'CALCULATE		decResult = setDecimal'											&& bug
? 'literal product		decResult = MAX(sum(decItems),setDecimal)'		&& incorrect
? 'literal division		decResult = MAX(sum(decItems),setDecimal)'		&& incorrect
? 'variable division	decResult = MAX(4,setDecimal+2)'						&& i can found words
? 'literal exponent		decResult = MAX(decFirstItem,setDecimal)'			&& incorrect
? 'TRANSFORM INTEGER	decResult = 0'													&& it is a design choice
? 'TRANSFORM DECIMAL	decResult = MAX(decItems,decProducts,setDecimal)'	&& incorrect
The only simplified rule is this.
SET DECIMAL TO 0
but it not resolve all.

Fabio
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform