On the other hand, when variables are set to DBL type, it does sometimes matter, and a better accuracy is generally attained if the computation is run in a single expression.
This because the FPU register use 80 bit precision anyhow, and when an expression is all evaluated inside the FPU registers, intermediate results are not rounded-off to 64 bits precision (as they are when transfer-to-memory takes place), resulting in a lower round-off error.
The following code shows the point:
Code:
[FONT="Courier New"][SIZE="3"] DEFDBL A-Z FUNCTION PBMAIN() A=10*ATN(10) B=SIN(A) PRINT USING$("##.################",B) C=SIN(10*ATN(10)) PRINT USING$("##.################",C) X##=10*ATN(10) Y##=SIN(X##) Z##=SIN(10*ATN(10)) PRINT USING$("##.#################",Y##) PRINT USING$("##.#################",Z##) WAITKEY$ END FUNCTION [/SIZE][/FONT]
Leave a comment: