Robert Prins

2017-08-03 19:09:59 UTC

Just came across the following, and please don't come back with pedantic

remarks about undeclared variables, the code is just to show what's there:

dcl sum fixed (7) init (-0.1);

for i = 1 to whatever;

if a(i) >= 0 then

sum = sum + a(i);

end;

if substr(unspec(sum), 25, 8) ^= '0d'bx then

put data(sum);

In other words if all a(i) are negative, nothing is printed. A comment in

the code suggests that this is faster code, on modern OoO z/OS systems,

than the more logical:

dcl sum fixed (7) init (-1);

for i = 1 to whatever;

if a(i) >= 0 then

if sum ^= -1 then

sum = sum + a(i);

else

sum = a(i);

end;

It probably is if the value of whatever is in the order of 42 gazillion,

but any other thoughts about this?

Robert

remarks about undeclared variables, the code is just to show what's there:

dcl sum fixed (7) init (-0.1);

for i = 1 to whatever;

if a(i) >= 0 then

sum = sum + a(i);

end;

if substr(unspec(sum), 25, 8) ^= '0d'bx then

put data(sum);

In other words if all a(i) are negative, nothing is printed. A comment in

the code suggests that this is faster code, on modern OoO z/OS systems,

than the more logical:

dcl sum fixed (7) init (-1);

for i = 1 to whatever;

if a(i) >= 0 then

if sum ^= -1 then

sum = sum + a(i);

else

sum = a(i);

end;

It probably is if the value of whatever is in the order of 42 gazillion,

but any other thoughts about this?

Robert

--

Robert AH Prins

***@gmail.com

Some programming @ <https://prino.neocities.org/zOS/zOS%20Tools.html>

----------------------------------------------------------------------

For IBM-MAIN subscribe / signoff / archive access instructions,

send email to ***@listserv.ua.edu with the message: INFO IBM-MAIN

Robert AH Prins

***@gmail.com

Some programming @ <https://prino.neocities.org/zOS/zOS%20Tools.html>

----------------------------------------------------------------------

For IBM-MAIN subscribe / signoff / archive access instructions,

send email to ***@listserv.ua.edu with the message: INFO IBM-MAIN