Post Reply 
Visibility of a var outside a cycle
03-09-2015, 01:39 PM
Post: #2
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;
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Visibility of a var outside a cycle - DrD - 03-09-2015 01:39 PM



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