Visibility of a var outside a cycle
03-09-2015, 01:39 PM
Post: #2
 DrD Senior Member Posts: 1,133 Joined: Feb 2014
RE: Visibility of a var outside a cycle
(03-09-2015 11:59 AM)salvomic Wrote:  now, tn is actually 1024 (i.e.), outside the FOR cycle "Return tn" give 1024, but "return tn^2) give 1449616 and not the right value (1048576); "return tn*2" give correctly 2048, "return tn*tn" give also 1449616...

How must I set the variable to give the correct value, also with tn^2 and so on, outside the cycle?

Thanks!

Salvo

Code food for thought:

Code:
 EXPORT Varb() BEGIN   local j, m:=10, tn:=0,DL:={};   FOR j FROM 1 TO m DO     DL:=CONCAT(DL,2);  //  Appending 10 two's to reach 1024 via gamma list   END;   tn:=ΠLIST(DL);  //  2^10 = 1024   return tn^2;  //  1024^2 = 1,048,576.00 END;
 « Next Oldest | Next Newest »

 Messages In This Thread Visibility of a var outside a cycle - salvomic - 03-09-2015, 11:59 AM RE: Visibility of a var outside a cycle - DrD - 03-09-2015 01:39 PM RE: Visibility of a var outside a cycle - salvomic - 03-09-2015, 01:51 PM RE: Visibility of a var outside a cycle - DrD - 03-09-2015, 02:27 PM RE: Visibility of a var outside a cycle - salvomic - 03-09-2015, 02:40 PM

User(s) browsing this thread: 1 Guest(s)