'boz' constants: but why z?

Sorry, a stupid question has never found an answer in my head: does anyone knows why z is used in ‘boz’ constants? :crazy_face:
https://gcc.gnu.org/onlinedocs/gfortran/BOZ-literal-constants.html

Why do we write z'ff0' for hexadecimal? Perhaps x'ff0' was avoided because it looks like a multiplication? Or because ‘box’ sounds like a box?
But why not h'ff0'? We would use ‘boh’ constants instead of ‘boz’, it’s not worse.

In most languages, we have that kind of prefix: 0x or &h, so I have never understood why it is a z in Fortran… :thinking: It always makes me think of Bozo the Clown :clown_face:. Was it chosen because it sounds fun?

1 Like

You’d be absolutely right in thinking of Bozo the Clown :clown_face: in connection with many matters Fortran-related! That’s also what led to many computational technologists and scientists preferring any number of other programming paradigms over Fortran since the 1970s!

As to why ‘Z’ in BOZ constants, I’m not completely sure but my hunch is it goes back to the days of IBM and FORTRAN IV. If correct, perhaps someone with background in IBM FORTRAN and programming language history might be able to shed more light for you as to why Z was picked.

I think IBM supported hexadecimal constants in FORTRAN IV as an extension, though without the quotes e.g., Z2A instead of Z’2A’ i.e., if I recall correctly from a legacy engineering FORTRAN program I had the “pleasure” of reauthoring not too long ago as a Microsoft .NET library assembly package. Going back to your ‘Bozo’ reference, humor has it one can write Fortran in any language which is what I ended up doing in C# with this program. The new code was fast, efficient, and bug-free but those with general IT background in charge of support hate it because of the programming style and conventions that are Fortranesque, or more like it’s numerical algorithmic library style reusable code they are not used to writing.

1 Like

This question came up when I wrote about BOZ constants in Doctor Fortran in “We’re All BOZos on This Bus” - Doctor Fortran (stevelionel.com) I didn’t know the answer at the time.

What I was told later was that it had to do with a choice of FORMAT edit descriptor for hexadecimal output. X was already taken, so Z was used. This predated MIL-STD-1753, which largely “standardized” existing practice. IBM had been using Z prior to F77 standardization. I know that VAX FORTRAN 1.0 (1978) supported both X and Z as letters for hex constants.

3 Likes

Ah yes, my Modern Fortran explained says nx can be used to place n spaces in a record. But what about ‘h’? Has it or had it a meaning in a format?

As you say “yes, I know Hexadecimal doesn’t start with Z, but what can you do?” Z is not even in the word, except hidden in the pronunciation of ‘Xa’… Does anyone knows another language using z?

I was also interested by:

hexadecimal didn’t really take off until 32-bit processors of the late 1970s, most notably the DEC VAX line.

It’s true it’s a way to write big integers with few characters, and was probably not felt necessary before. There is still some octal in commands like chmod 600 but it is now rarely used.

Let’s also quote your final sentence:

I do want to leave you with an important note – BOZ constants are not integers! They are, as Fortran 2008 finally nailed down, a sequence of bits whose interpretation depends on their context.

But what about ‘h’? Has it or had it a meaning in a format?

Hollerith constants.

2 Likes

@interkosmos

Even more fun, you can READ into a H edit descriptor in a FORMAT! (At least, you could in F66 and many compilers still support this today.)

1 Like

Can’t imagine any case where this might be useful …

It was used for reading titles for reports. This was before CHARACTER - you would have something like 40H (and 40 blanks), then do a read of a card with this format. The next 40 characters would replace the blanks in the H format, and you could then write with that format later and get the title.

3 Likes
D:\Projects>type test.f90
read (*,101)
101 format (20H12345678901234567890)
write (*,101)
end
D:\Projects>ifort test.f90
Intel(R) Fortran Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.2.0 Build 20210228_000000
Copyright (C) 1985-2021 Intel Corporation.  All rights reserved.

Microsoft (R) Incremental Linker Version 14.28.29913.0
Copyright (C) Microsoft Corporation.  All rights reserved.

-out:test.exe
-subsystem:console
test.obj

D:\Projects>test.exe
Hello World!
Hello World!
2 Likes

The Format specifier for converting a numeric value to a Hexadecimal output is Z. (The X format specifier was already taken for a different purpose.) Just speculation, but that might have had something to do with using Z (and, in particular, NOT using X) as part of the syntax for literal constants.

1 Like

I asked the same question a long time ago. Lew Ondis II, who had been using Fortran for years when he wrote the ACM request “On behalf of FORTRAN” in 1965 and called it a commonly used language then (which might be a surprise to some peoples’ idea of the timeline of Fortran) said there was a long enough discussion about it that everyone was getting tired of it, and that “H” and “ABCDEF” and all the other letters in use had been eliminated when it almost became “S” for sixteen, but the way the strongest proponent pronounced it (“sechsteen”) sounded enough like an English Z that someone jokingly said “then ‘Z’ it is”; and someone else said “yeah, what else would we use ‘Z’ for?”. Unfortunately, he is no longer around so I am not totally sure if he was teasing or not after all these years. Quotes were not commonly used at that time by the way, so H was reserved for "Hollerith"s for those who wonder about “H” being in use, as it is rarely used today. There were few other languages in use (not sure what ALGOL had anymore) so comparing to other languages today ends up not being relevant. Either way, I have remembered that it is “Z” for “Zixteen” ever since.

5 Likes

Thanks @urbanjost for that story! So I was right, it’s for fun! Finally boz is quite like GNU…

Maybe a German computer scientist? And he could have been pleased with the Z, like Konrad Zuse with its Z1, Z2, Z3, Z4… Note also that in German, hexadecimal is Hexadezimalsystem.
Some other prefixes and suffixes are cited in that page (but no z…):

Verbreitete Schreibweisen sind: 72_{16}, 72_{hex}, 72h, 72H, 72_H, 0x72, $72, "72 und X’72’, wobei das Präfix 0x und das Suffix h insbesondere in der Programmierung und technischen Informatik Verwendung finden.

1 Like