ArticleslgStudy

computer science

Hollerith constant

Hollerith constant is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Hollerith constant rather than just read about it. In short: Hollerith constants, named in honor of Herman Hollerith, were used in early FORTRAN programs to allow manipulation of character data. Early FORTRAN had no CHARACTER data type, only numeric types.

Key takeaways

  • Hollerith constant belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Hollerith constant to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Hollerith constant from memory before moving on to harder problems.

Reference excerpt

Hollerith constants, named in honor of Herman Hollerith, were used in early FORTRAN programs to allow manipulation of character data. Early FORTRAN had no CHARACTER data type, only numeric types. In order to perform character manipulation, characters needed to be placed into numeric variables using Hollerith constants. For example, the constant 3HABC specified a three-character string "ABC", identified by the initial integer representing the string length 3 and the specified Hollerith character H, followed by the string data ABC. These constants were typeless, so that there were no type conversion issues. If the constant specified fewer characters than was possible to hold in a data item, the characters were then stored in the item left-justified and blank-filled.

Mechanics By the FORTRAN 66 Standard, Hollerith syntax was allowed in the following uses:

As constants in DATA statements As constant actual arguments in subroutine CALL statements As edit descriptors in FORMAT statements Portability was problematic with Hollerith constants. First, word sizes varied on different computer systems, so the number of characters that could be placed in each data item likewise varied. Implementations varied from as few as two to as many as ten characters per word. Second, it was difficult to manipulate individual characters within a word in a portable fashion. This led to a great deal of shifting and masking code using non-standard, vendor-specific, features. The fact that character sets varied between machines also complicated the issue. Some authors were of the opinion that for best portability, only a single character should be used per data item. However considering the small memory sizes of machines of the day, this technique was considered extremely wasteful.

Technological obsolescence One of the major features of FORTRAN 77 was the CHARACTER string data type. Use of this data type dramatically simplified character manipulation in Fortran programs – rendering almost all uses of the Hollerith constant technique obsolete. Hollerith constants were removed from the FORTRAN 77 Standard, though still described in an appendix for those wishing to continue support. Hollerith edit descriptors were allowed through Fortran 90, and were removed from the Fortran 95 Standard.

Examples The following is a FORTRAN 66 hello world program using Hollerith constants. It assumes that at least four characters per word are supported by the implementation:

Besides DATA statements, Hollerith constants were also allowed as actual arguments in subroutine calls. However, there was no way that the callee could know how many characters were passed in. The programmer had to pass the information explicitly. The hello world program could be written as follows – on a machine where four characters are stored in a word:

PROGRAM HELLO2 CALL WRTOUT (11HHELLO WORLD, 11) STOP END C SUBROUTINE WRTOUT (IARRAY, NCHRS) C INTEGER IARRAY(1) INTEGER NCHRS C INTEGER ICPW DATA ICPW/4/ INTEGER I, NWRDS C NWRDS = (NCHRS + ICPW - 1) /ICPW WRITE (6,100) (IARRAY(I), I=1,NWRDS) RETURN 100 FORMAT (100A4) END

Although technically not a Hollerith constant, the same Hollerith syntax was allowed as an edit descriptor in FORMAT statements. The hello world program could also be written as:

One of the most surprising features was the behaviour of Hollerith edit descriptors when used for input. The following program would change at run time HELLO WORLD to whatever would happen to be the next eleven characters in the input stream and print that input:

Notes

References

American Standard FORTRAN. American Standards Association, X3.9-1966. p. 38.

Worked examples

Example 1 — a first encounter with Hollerith constant

Start with the simplest possible case. Write down what Hollerith constant claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Hollerith constant before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Hollerith constant ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Hollerith constant

In research
Hollerith constant appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Hollerith constant in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Hollerith constant is common in secondary-school and first-year university syllabi. It links to neighbouring topics Fortran, String data structures, so understanding it makes those chapters shorter.
In everyday life
Look for Hollerith constant outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Hollerith constant in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Hollerith constant means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Hollerith constant out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Hollerith constant in simple terms?

Hollerith constants, named in honor of Herman Hollerith, were used in early FORTRAN programs to allow manipulation of character data. Early FORTRAN had no CHARACTER data type, only numeric types.

Why does Hollerith constant matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Hollerith constant?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Hollerith constant.

Tags

  • Fortran
  • String data structures

Keep exploring