The IBM documentation for the ICLZ builtin says this:
If the argument x is of the type SIGNED FIXED BIN(p) with p <= 15, it is
converted to SIGNED FIXED BIN(31). If it is of the type UNSIGNED FIXED BIN(p)
with p <= 16, it is converted to UNSIGNED FIXED BIN(32).
So, in this example; I expect the argument 'k' to be converted to an
UNSIGNED FIXED BIN(32):
test: proc options(main);
dcl res fixed bin(31);
dcl k unsigned fixed bin(16);
k = 1;
res = ICLZ(k);
display('RES is ' || res);
end;
And - thus, the result of the ICLZ on a value of X'1' with a 32-bit
integer parameter would
be 31.
However, when you execute this program, the result is 15 - which
indicates it's
not being treated as an UNSIGNED FIXED BIN(32).
Is this a doc error, or a compiler-error, or am I misunderstanding the documentation?
On 3/7/22 1:25 AM, Thomas David Rivers wrote:
The IBM documentation for the ICLZ builtin says this:
If the argument x is of the type SIGNED FIXED BIN(p) with p <= 15, >> it is
converted to SIGNED FIXED BIN(31). If it is of the type UNSIGNED
FIXED BIN(p)
with p <= 16, it is converted to UNSIGNED FIXED BIN(32).
So, in this example; I expect the argument 'k' to be converted to an
UNSIGNED FIXED BIN(32):
test: proc options(main);
dcl res fixed bin(31);
dcl k unsigned fixed bin(16);
k = 1;
res = ICLZ(k);
display('RES is ' || res);
end;
And - thus, the result of the ICLZ on a value of X'1' with a 32-bit
integer parameter would
be 31.
However, when you execute this program, the result is 15 - which
indicates it's
not being treated as an UNSIGNED FIXED BIN(32).
Is this a doc error, or a compiler-error, or am I misunderstanding the
documentation?
The documentation seems messy. For one thing, it does not allow for
64-bit numbers. Given that, I don’t trust it.
John W Kennedy <john.w.kennedy@gmail.com> wrote:
On 3/7/22 1:25 AM, Thomas David Rivers wrote:
The IBM documentation for the ICLZ builtin says this:
If the argument x is of the type SIGNED FIXED BIN(p) with p <= 15,
it is
converted to SIGNED FIXED BIN(31). If it is of the type UNSIGNED >>> FIXED BIN(p)
with p <= 16, it is converted to UNSIGNED FIXED BIN(32).
So, in this example; I expect the argument 'k' to be converted to an
UNSIGNED FIXED BIN(32):
test: proc options(main);
dcl res fixed bin(31);
dcl k unsigned fixed bin(16);
k = 1;
res = ICLZ(k);
display('RES is ' || res);
end;
And - thus, the result of the ICLZ on a value of X'1' with a 32-bit
integer parameter would
be 31.
However, when you execute this program, the result is 15 - which
indicates it's
not being treated as an UNSIGNED FIXED BIN(32).
Is this a doc error, or a compiler-error, or am I misunderstanding the
documentation?
The documentation seems messy. For one thing, it does not allow for
64-bit numbers. Given that, I don’t trust it.
The documentation has been going downhill since PL/I(F). Newer features are all poorly documented. The only way to find out how some things work is to actually use them. In this particular case, though, if it’s not a bug there’s a possibility that the implementation changed but the reference was not updated to match.
The IBM documentation for the ICLZ builtin says this:.
If the argument x is of the type SIGNED FIXED BIN(p) with p <= 15,
it is
converted to SIGNED FIXED BIN(31). If it is of the type UNSIGNED
FIXED BIN(p)
with p <= 16, it is converted to UNSIGNED FIXED BIN(32).
So, in this example; I expect the argument 'k' to be converted to an
UNSIGNED FIXED BIN(32):
test: proc options(main);
dcl res fixed bin(31);
dcl k unsigned fixed bin(16);
k = 1;
res = ICLZ(k);
display('RES is ' || res);
end;
And - thus, the result of the ICLZ on a value of X'1' with a 32-bit
integer parameter would be 31.
However, when you execute this program, the result is 15 - which.
indicates it's not being treated as an UNSIGNED FIXED BIN(32).
Is this a doc error, or a compiler-error, or am I misunderstanding the documentation?
The IBM documentation for the ICLZ builtin says this:.
If the argument x is of the type SIGNED FIXED BIN(p) with p <= 15,.
it is
converted to SIGNED FIXED BIN(31). If it is of the type UNSIGNED
FIXED BIN(p)
with p <= 16, it is converted to UNSIGNED FIXED BIN(32).
So, in this example; I expect the argument 'k' to be converted to an
UNSIGNED FIXED BIN(32):
test: proc options(main);
dcl res fixed bin(31);
dcl k unsigned fixed bin(16);
k = 1;
res = ICLZ(k);
display('RES is ' || res);
end;
And - thus, the result of the ICLZ on a value of X'1'
with a 32-bit integer parameter would.
be 31..
However, when you execute this program, the result is 15 - which.
indicates it's
not being treated as an UNSIGNED FIXED BIN(32).
Is this a doc error, or a compiler-error, or am I misunderstanding the documentation?.
On Tuesday, March 8, 2022 at 12:12:24 PM UTC+11, Thomas David Rivers wrote:
The IBM documentation for the ICLZ builtin says this:.
If the argument x is of the type SIGNED FIXED BIN(p) with p <= 15,
it is
converted to SIGNED FIXED BIN(31). If it is of the type UNSIGNED
FIXED BIN(p)
with p <= 16, it is converted to UNSIGNED FIXED BIN(32).
So, in this example; I expect the argument 'k' to be converted to an >>UNSIGNED FIXED BIN(32):
test: proc options(main);
dcl res fixed bin(31);
dcl k unsigned fixed bin(16);
k = 1;
res = ICLZ(k);
display('RES is ' || res);
end;
And - thus, the result of the ICLZ on a value of X'1' with a 32-bit
integer parameter would be 31.
What? Why would it not be 1 ?
.
However, when you execute this program, the result is 15 - which.
indicates it's not being treated as an UNSIGNED FIXED BIN(32).
You haven't made it clear what you are doing.
Your program should print the value 1.
.
Robin Vowels wrote:
On Tuesday, March 8, 2022 at 12:12:24 PM UTC+11, Thomas David Rivers wrote: >>That is the entire program, and the output of the program is:
The IBM documentation for the ICLZ builtin says this:.
If the argument x is of the type SIGNED FIXED BIN(p) with p <= 15,
it is
converted to SIGNED FIXED BIN(31). If it is of the type UNSIGNED
FIXED BIN(p)
with p <= 16, it is converted to UNSIGNED FIXED BIN(32).
So, in this example; I expect the argument 'k' to be converted to an
UNSIGNED FIXED BIN(32):
test: proc options(main);
dcl res fixed bin(31);
dcl k unsigned fixed bin(16);
k = 1;
res = ICLZ(k);
display('RES is ' || res);
end;
And - thus, the result of the ICLZ on a value of X'1' with a 32-bit
integer parameter would be 31.
What? Why would it not be 1 ?
.
However, when you execute this program, the result is 15 - which.
indicates it's not being treated as an UNSIGNED FIXED BIN(32).
You haven't made it clear what you are doing.
Your program should print the value 1.
.
RES is 15
The ICLZ builtin function counts the number of leading zeros
in the underlying representation of the value; which depends on
the size of that representation.
The IBM documentation seems to, possibly, indicate that any value
represented by a datum smaller than a 4-byte integer is first converted
to a 4-byte
integer. Which means that the number of leading zeros in such a representation
would be a value in the range 0 to 32 (although the count-leading-zeros operation is
undefined for a zero value, and in some hardware, e.g. x86, returns
strange results,
so a careful program would check for a zero value, and the actual range
of the
count-leading-zeros operation should be considered to be 0 to 31.)
This program demonstrates that, contrary to the documentation, the compiler is not converting the value to a 4-byte integer to determine the count
of leading zero bits
but is instead using the underlying represenation of the value, a 2-byte integer.
In this case, an UNSIGNED FIXED BINARY value with a precision of 16 can
have an underlying representation of 2 bytes (16 bits.) A value of 1 would then be in binary: 00000000 00000001 and thus have 15 leading zeros; hence the result of 15.
Note that if the conversion to a FIXED BIN(31) had occured, as mentioned in the documentation, the underlying representation would require 4 bytes
(32 bits) and
the result would be 31, not 15 (31 leading zero bits followed by a 1 bit.)
As to why one might wish to use the count-leading-zeros operation, I refer you to the Wikipedia page that describes this and related operations and their applications:
https://en.wikipedia.org/wiki/Find_first_set
As to the IBM documentation, the complete documentation on the ICLZ
builtin function can be found at the IBM web site, which you can arrive
at by
following this link:
https://www.ibm.com/docs/en/epfz/5.3?topic=subroutines-iclz
This is it, in its entirety (although re-formatted for posting):
ICLZ
Last Updated: 2021-09-08
ICLZ returns a FIXED BIN(31) value that indicates the number of
leading zeros in
a FIXED BIN value.
>>----- ICLZ( x ) ------ ><
x
Specifies a REAL FIXED BIN value with a scale factor of zero.
If the argument x is of the type SIGNED FIXED BIN(p) with p <= 15, it
is converted to
SIGNED FIXED BIN(31). If it is of the type UNSIGNED FIXED BIN(p) with
p <= 16, it is
converted to UNSIGNED FIXED BIN(32).
I did receive a reply from IBM regarding this, mentioning that they are having
some difficulties responding to the thread. Their e-mail noted that the documentation will be corrected to reflect the compiler's behavior.
So, this
is a documentation error.
I just wanted to answer Robin's questions, and put an end to this thread
for any future reader.
Robin Vowels wrote:
On Tuesday, March 8, 2022 at 12:12:24 PM UTC+11, Thomas David Rivers wrote:
The IBM documentation for the ICLZ builtin says this:
If the argument x is of the type SIGNED FIXED BIN(p) with p <= 15,
it is
converted to SIGNED FIXED BIN(31). If it is of the type UNSIGNED
FIXED BIN(p)
with p <= 16, it is converted to UNSIGNED FIXED BIN(32).
So, in this example; I expect the argument 'k' to be converted to an >>UNSIGNED FIXED BIN(32):
test: proc options(main);
dcl res fixed bin(31);
dcl k unsigned fixed bin(16);
k = 1;
res = ICLZ(k);
display('RES is ' || res);
end;
And - thus, the result of the ICLZ on a value of X'1' with a 32-bit >>integer parameter would be 31.
On 3/8/22 1:17 PM, Peter Flass wrote:.
John W Kennedy <john.w....@gmail.com> wrote:
On 3/7/22 1:25 AM, Thomas David Rivers wrote:
The IBM documentation for the ICLZ builtin says this:
If the argument x is of the type SIGNED FIXED BIN(p) with p <= 15, >>> it is
converted to SIGNED FIXED BIN(31). If it is of the type UNSIGNED >>> FIXED BIN(p)
with p <= 16, it is converted to UNSIGNED FIXED BIN(32).
So, in this example; I expect the argument 'k' to be converted to an
UNSIGNED FIXED BIN(32):
test: proc options(main);
dcl res fixed bin(31);
dcl k unsigned fixed bin(16);
k = 1;
res = ICLZ(k);
display('RES is ' || res);
end;
And - thus, the result of the ICLZ on a value of X'1' with a 32-bit
integer parameter would
be 31.
However, when you execute this program, the result is 15 - which
indicates it's
not being treated as an UNSIGNED FIXED BIN(32).
Is this a doc error, or a compiler-error, or am I misunderstanding the >>> documentation?
The documentation seems messy. For one thing, it does not allow for
64-bit numbers. Given that, I don’t trust it.
The documentation has been going downhill since PL/I(F). Newer features areI have often referred here to the old PL/I Language Specification (not updated since 1968) as the only available answer to many corner cases. Unfortunately, the ICLZ function is of too recent vintage.
all poorly documented. The only way to find out how some things work is to actually use them. In this particular case, though, if it’s not a bug there’s a possibility that the implementation changed but the reference was
not updated to match.
And, unlike Ada, PL/I documentation rarely makes a clear distinction
between the declared type of a variable and the hardware type that
underlies it, and that seems to be in play here.
Nope, sorry:-; Does this mean that ICLZ of a fixed bin(31) negative number would return zero?.
On Wednesday, March 16, 2022 at 7:33:01 AM UTC+11, bearlyabus...@gmail.com wrote:
Nope, sorry:-; Does this mean that ICLZ of a fixed bin(31) negative number >> would return zero?.
It would raise SIZE and/or FIXEDOVERFLOW.
On 3/16/22 6:35 AM, Robin Vowels wrote:.
On Wednesday, March 16, 2022 at 7:33:01 AM UTC+11, bearlyabus...@gmail.com wrote:
Nope, sorry:-; Does this mean that ICLZ of a fixed bin(31) negative number >> would return zero?.
It would raise SIZE and/or FIXEDOVERFLOW.
Why on Earth would it?.
On Thursday, March 17, 2022 at 8:40:08 AM UTC+11, John W. Kennedy wrote:
On 3/16/22 6:35 AM, Robin Vowels wrote:.
On Wednesday, March 16, 2022 at 7:33:01 AM UTC+11, bearlyabus...@gmail.com wrote:
Nope, sorry:-; Does this mean that ICLZ of a fixed bin(31) negative number >>>> would return zero?.
It would raise SIZE and/or FIXEDOVERFLOW.
Why on Earth would it?.
Because it's PL/I, not some mickey-mouse language like C or Fortran.
.
Does this satisfy you?
.
(FOFL, SIZE):
TEST: PROCEDURE OPTIONS (MAIN);
DECLARE US UNSIGNED FIXED BINARY (31);
DECLARE S FIXED BINARY (31) ;
S = -12345;
US = S;
PUT DATA (US);
END TEST;
.
OUTPUT:
.
IBM0342I ONCODE=0340 The SIZE condition was raised.
At offset +???????? in procedure with entry TEST
PL/I tells you when significant digits are lost.
Robin Vowels <robin....@gmail.com> wrote:.
On Thursday, March 17, 2022 at 8:40:08 AM UTC+11, John W. Kennedy wrote:
On 3/16/22 6:35 AM, Robin Vowels wrote:.
On Wednesday, March 16, 2022 at 7:33:01 AM UTC+11, bearlyabus...@gmail.com wrote:
Nope, sorry:-; Does this mean that ICLZ of a fixed bin(31) negative number.
would return zero?
It would raise SIZE and/or FIXEDOVERFLOW.
Why on Earth would it?.
Because it's PL/I, not some mickey-mouse language like C or Fortran.
.
Does this satisfy you?
.
(FOFL, SIZE):
TEST: PROCEDURE OPTIONS (MAIN);
DECLARE US UNSIGNED FIXED BINARY (31);
DECLARE S FIXED BINARY (31) ;
S = -12345;
US = S;
PUT DATA (US);
END TEST;
.
OUTPUT:
.
IBM0342I ONCODE=0340 The SIZE condition was raised.
At offset +???????? in procedure with entry TEST
PL/I tells you when significant digits are lost.
How about if US is precision (32)?
Nope, sorry:-; Does this mean that ICLZ of a fixed bin(31) negative number >would return zero?
Robin Vowels <robin....@gmail.com> wrote:.
On Thursday, March 17, 2022 at 8:40:08 AM UTC+11, John W. Kennedy wrote:
On 3/16/22 6:35 AM, Robin Vowels wrote:.
On Wednesday, March 16, 2022 at 7:33:01 AM UTC+11, bearlyabus...@gmail.com wrote:
Nope, sorry:-; Does this mean that ICLZ of a fixed bin(31) negative number.
would return zero?
It would raise SIZE and/or FIXEDOVERFLOW.
Why on Earth would it?.
Because it's PL/I, not some mickey-mouse language like C or Fortran.
.
Does this satisfy you?
.
(FOFL, SIZE):
TEST: PROCEDURE OPTIONS (MAIN);
DECLARE US UNSIGNED FIXED BINARY (31);
DECLARE S FIXED BINARY (31) ;
S = -12345;
US = S;
PUT DATA (US);
END TEST;
.
OUTPUT:
.
IBM0342I ONCODE=0340 The SIZE condition was raised.
At offset +???????? in procedure with entry TEST
PL/I tells you when significant digits are lost.
How about if US is precision (32)?
On Friday, March 18, 2022 at 6:31:51 AM UTC+11, bearlyabus...@gmail.com wrote:
Robin Vowels <robin....@gmail.com> wrote:.
On Thursday, March 17, 2022 at 8:40:08 AM UTC+11, John W. Kennedy wrote: >>>> On 3/16/22 6:35 AM, Robin Vowels wrote:How about if US is precision (32)?
.On Wednesday, March 16, 2022 at 7:33:01 AM UTC+11, bearlyabus...@gmail.com wrote:
Nope, sorry:-; Does this mean that ICLZ of a fixed bin(31) negative number.
would return zero?
It would raise SIZE and/or FIXEDOVERFLOW.
Why on Earth would it?.
Because it's PL/I, not some mickey-mouse language like C or Fortran.
.
Does this satisfy you?
.
(FOFL, SIZE):
TEST: PROCEDURE OPTIONS (MAIN);
DECLARE US UNSIGNED FIXED BINARY (31);
DECLARE S FIXED BINARY (31) ;
S = -12345;
US = S;
PUT DATA (US);
END TEST;
.
OUTPUT:
.
IBM0342I ONCODE=0340 The SIZE condition was raised.
At offset +???????? in procedure with entry TEST
PL/I tells you when significant digits are lost.
Exactly the same result.
Peter Flass wrote:
Yes - it would return 0 as there would be zero leading zero-bits in the representation.
Nope, sorry:-; Does this mean that ICLZ of a fixed bin(31) negative
number
would return zero?
The count-leading-zeros operation is mostly used with unsigned values.
- Dave R. -
On 3/17/22 2:57 AM, Thomas David Rivers wrote:.
Peter Flass wrote:
Yes - it would return 0 as there would be zero leading zero-bits in the representation.
Nope, sorry:-; Does this mean that ICLZ of a fixed bin(31) negative
number
would return zero?
The count-leading-zeros operation is mostly used with unsigned values.
To begin with, unlike many modern languages, PL/I doesn’t define BINARY FIXED as 2’s complement (reasonably enough; IBM had not used 2’s-complement before),.
so ICLZ doesn’t have a defined value for a.
negative input at all.
It also isn’t defined for p>32 (UNSIGNED) or p>31.
(SIGNED).
Supposedly someone had a use for this operation.
I could not find whether System z had a hardware instruction
for this task.
.
The CDC Cyber had a population count instruction
that counted the 1-bits in a binary word.
.
On DEUCE there was a need for such an operation,
though there was no such instruction.
.
However, the task was possible using the multiplier
as a shift register, and by simultaneously adding
the contents of the multiplier register to an accumulator.
(c. 1960)
On Saturday, March 19, 2022 at 11:55:57 AM UTC+11, John W. Kennedy wrote:
On 3/17/22 2:57 AM, Thomas David Rivers wrote:.
Peter Flass wrote:
Yes - it would return 0 as there would be zero leading zero-bits in the
Nope, sorry:-; Does this mean that ICLZ of a fixed bin(31) negative
number
would return zero?
representation.
The count-leading-zeros operation is mostly used with unsigned values.
To begin with, unlike many modern languages, PL/I doesn’t define BINARY.
FIXED as 2’s complement (reasonably enough; IBM had not used
2’s-complement before),
Whether or not that is true, twos complement representation was
used from the year 1950 and earlier, and has been the most widely-used
for binary representation.
so ICLZ doesn’t have a defined value for a.
negative input at all.
That doesn't follow; the value could be defined by negating the value
and then counting the leading zeros.
.
It also isn’t defined for p>32 (UNSIGNED) or p>31.
(SIGNED).
There's no reason that it couldn't be defined when the argument
is 64 bits.
On 3/19/22 12:15 AM, Robin Vowels wrote:.
On Saturday, March 19, 2022 at 11:55:57 AM UTC+11, John W. Kennedy wrote:
On 3/17/22 2:57 AM, Thomas David Rivers wrote:.
Peter Flass wrote:
Yes - it would return 0 as there would be zero leading zero-bits in the >>> representation.
Nope, sorry:-; Does this mean that ICLZ of a fixed bin(31) negative >>>> number
would return zero?
The count-leading-zeros operation is mostly used with unsigned values.
To begin with, unlike many modern languages, PL/I doesn’t define BINARY >> FIXED as 2’s complement (reasonably enough; IBM had not used.
2’s-complement before),
Whether or not that is true, twos complement representation was
used from the year 1950 and earlier, and has been the most widely-used
for binary representation.
Not by IBM.
.so ICLZ doesn’t have a defined value for a.
negative input at all.
That doesn't follow; the value could be defined by negating the value
and then counting the leading zeros.
“Could be defined” is the opposite of “defined”.
Again, what matters is that it /isn’t/ defined. This is what aIt also isn’t defined for p>32 (UNSIGNED) or p>31 (SIGNED)..
There's no reason that it couldn't be defined when the argument
is 64 bits.
definition looks like: it’s the definition of the z/Architecture FLOGR instruction:
FIND LEFTMOST ONE
On Sunday, March 20, 2022 at 5:20:06 AM UTC+11, John W. Kennedy wrote:
On 3/19/22 12:15 AM, Robin Vowels wrote:.
On Saturday, March 19, 2022 at 11:55:57 AM UTC+11, John W. Kennedy wrote: >>>> On 3/17/22 2:57 AM, Thomas David Rivers wrote:
.Peter Flass wrote:To begin with, unlike many modern languages, PL/I doesn’t define BINARY >>>> FIXED as 2’s complement (reasonably enough; IBM had not used
Yes - it would return 0 as there would be zero leading zero-bits in the >>>>> representation.
Nope, sorry:-; Does this mean that ICLZ of a fixed bin(31) negative >>>>>> number
would return zero?
The count-leading-zeros operation is mostly used with unsigned values. >>> .
2’s-complement before),
Whether or not that is true, twos complement representation was
used from the year 1950 and earlier, and has been the most widely-used
for binary representation.
Not by IBM.
so what? I didn't say that it was.
.
.so ICLZ doesn’t have a defined value for a.
negative input at all.
That doesn't follow; the value could be defined by negating the value
and then counting the leading zeros.
“Could be defined” is the opposite of “defined”.
What?
Again, what matters is that it /isn’t/ defined. This is what aIt also isn’t defined for p>32 (UNSIGNED) or p>31 (SIGNED)..
There's no reason that it couldn't be defined when the argument
is 64 bits.
definition looks like: it’s the definition of the z/Architecture FLOGR
instruction:
FIND LEFTMOST ONE
What's surprising is that the instruction has been available since at least 2008.
It is therefore even more surprising that ICLZ has not been defined for a 64-bit
operand. Really perverse.
But I was talking about why is is unsurprising that IBM did not define.
PL/I as using 2's-complement, as the designers of (say) Java and Swift
did. (But consider that the designers of Ada did not. In fact they had
to insert an ad-hoc clause /allowing/ 2's-complement.) To IBM and its customers in the early 60s, 2's-complement was an exotic and daring experiment.
On Monday, March 21, 2022 at 8:23:00 AM UTC+11, John W. Kennedy wrote:
But I was talking about why is is unsurprising that IBM did not define.
PL/I as using 2's-complement, as the designers of (say) Java and Swift
did. (But consider that the designers of Ada did not. In fact they had
to insert an ad-hoc clause /allowing/ 2's-complement.) To IBM and its
customers in the early 60s, 2's-complement was an exotic and daring
experiment.
Not to us. At our site, twos complement equipment had been used
for 10 years before S/360.
And twos complement was not an "experiment". It was used on
Pilot ACE (1951), etc
On 3/26/22 12:33 AM, Robin Vowels wrote:
On Monday, March 21, 2022 at 8:23:00 AM UTC+11, John W. Kennedy wrote:
But I was talking about why is is unsurprising that IBM did not define.
PL/I as using 2's-complement, as the designers of (say) Java and Swift
did. (But consider that the designers of Ada did not. In fact they had
to insert an ad-hoc clause /allowing/ 2's-complement.) To IBM and its
customers in the early 60s, 2's-complement was an exotic and daring
experiment.
Not to us. At our site, twos complement equipment had been used
for 10 years before S/360.
And twos complement was not an "experiment". It was used on
Pilot ACE (1951), etc
And so? If the National Physical Laboratory
had had any major input in the language
eventually to be known as PL/I, there wouldn’t have been
the embarrassing public kerfuffle over the name.
On Sunday, March 27, 2022 at 11:19:01 AM UTC+11, John W. Kennedy wrote:
On 3/26/22 12:33 AM, Robin Vowels wrote:
On Monday, March 21, 2022 at 8:23:00 AM UTC+11, John W. Kennedy wrote:
But I was talking about why is is unsurprising that IBM did not define >>>> PL/I as using 2's-complement, as the designers of (say) Java and Swift >>>> did. (But consider that the designers of Ada did not. In fact they had >>>> to insert an ad-hoc clause /allowing/ 2's-complement.) To IBM and its.
customers in the early 60s, 2's-complement was an exotic and daring
experiment.
Not to us. At our site, twos complement equipment had been used
for 10 years before S/360.
And twos complement was not an "experiment". It was used on
Pilot ACE (1951), etc
And so? If the National Physical Laboratory
How is this relevant?
had had any major input in the language
The NPL was not into language design. It was into
numerical work and construction of computers.
eventually to be known as PL/I, there wouldn’t have been
the embarrassing public kerfuffle over the name.
How is this relevant?
The choice of name was the sole prerogative of IBM.
The IBM documentation for the ICLZ builtin says this:.
If the argument x is of the type SIGNED FIXED BIN(p) with p <= 15,
it is
converted to SIGNED FIXED BIN(31). If it is of the type UNSIGNED
FIXED BIN(p)
with p <= 16, it is converted to UNSIGNED FIXED BIN(32).
So, in this example; I expect the argument 'k' to be converted to an
UNSIGNED FIXED BIN(32):
test: proc options(main);
dcl res fixed bin(31);
dcl k unsigned fixed bin(16);
k = 1;
res = ICLZ(k);
display('RES is ' || res);
end;
And - thus, the result of the ICLZ on a value of X'1' with a 32-bit
integer parameter would
be 31.
However, when you execute this program, the result is 15 - which
indicates it's
not being treated as an UNSIGNED FIXED BIN(32).
Is this a doc error, or a compiler-error, or am I misunderstanding the documentation?
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 365 |
Nodes: | 16 (2 / 14) |
Uptime: | 21:53:07 |
Calls: | 7,788 |
Calls today: | 3 |
Files: | 12,917 |
Messages: | 5,750,755 |