Hi Garrett,
-------
Interesting. One question, though:
> varDec1 = 3.1255
> varDec4 = 2.5567
> ? '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
-------
A typed error:
? 'literal product ',3.1*2.5567
-----------
Did you mean the numbers in the above to match -- in other words, did you intend to use 3.1255 in your literals, as well as your variables?
-----------
Numbers are not important, important is the rules that VFP use for set result decimals;
rule change with type operation and type of source.
Code for focus on division
SET FIXED OFF
SET TALK OFF
CLEAR
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
? 'literal division ',3.1255/2.5567
? 'literal division ',3.1255/m.varDec4
? 'literal division ',m.varDec1/2.5567
? 'variable division ',m.varDec1/m.varDec4
RELEASE varDec1,varDec4
NEXT
?
? '******* Rule to compute decimals on division *******'
? 'literal division decResult = MAX(sum(decItems),setDecimal)'
? 'variable division decResult = MAX(4,setDecimal+2)'
If you want my opinion, the best choice, for any computation, is:
decResult = MAX(decimalForExpression,setDecimaltoValue) because with SET DECIMAL TO 0 i can remove the MAX and use only decimalForExpression,
or i can set a minimum decimal for any computation.
For decimalForExpression math rules can to be used ( and VFP use they in some cases):
addition : MAX(member1Decimal,member2Decimal,...)
product : SUM(member1Decimal,member2Decimal,...)
...
The principle is :
only 1 rule that the developer it must remember This is only my opinion, for simplified my job.
Fabio