On Tuesday, August 11, 2020 at 1:45:16 PM UTC-7, Steve Lionel wrote:
We decided not to do BITS for 202X. Adding a completely new datatype to
the language causes great upheaval, not only for the standard but also
for compiler writers. The general feeling was that enhancing BOZ plus
the extensive existing bit intrinsics suffices for most uses.
For comparison purposes, not that I necessarily think it would be a
good way to do it in Fortran, PL/I has bit strings. The same operations (such as substring) work as on character strings. This goes back close
to the beginning of PL/I.
The built-in function UNSPEC converts a variable of any type to a bit string.
The pseudo-variable UNSPEC converts bit string to another type.
DCL I FIXED BIN(31,0), X FLOAT BIN(21);
I=1;
X=10;
PUT LIST(UNSPEC(I), UNSPEC(X));
should get you something like:
'00000000000000000000000000000001'B,
'01000001101000000000000000000000'B;
(I am not sure now which end it pads when doing the conversions to/from BIT strings.)
DCL Y FLOAT BIN(21);
UNSPEC(Y)='01000010011001000000000000000000'B;
should set Y to 100.
Otherwise, PL/I constants have the base, scale, mode, and precision
in which they are written. Fortunately conversions most often work well.
123.0 is FIXED DEC(4,1), that is fixed point decimal with one digit
after the decimal point.
1100100B is FIXED BIN(7,0) with the decimal value 100.
Floating point constants have an exponent.
123.0e0 is FLOAT DEC(4)
Note that like Fortran's SELECTED_xxx_KIND, which specifies precision
in decimal digits, PL/I's DECIMAL base is not necessarily implemented
in decimal arithmetic, especially for floating point.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 365 |
Nodes: | 16 (2 / 14) |
Uptime: | 98:50:25 |
Calls: | 7,779 |
Calls today: | 1 |
Files: | 12,914 |
Messages: | 5,750,320 |