Hollerith constant

Hollerith constant

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 via Hollerith constants. For example the constant 3HABC specified a three-character string '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".

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.

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 deleted 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 deleted 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:

C PROGRAM HELLO1 C INTEGER IHWSTR(3) DATA IHWSTR/4HHELL,4HO WO, 3HRLD/ C WRITE (6,100) IHWSTR STOP 100 FORMAT (3A4) END

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:

C PROGRAM HELLO2 CALL WRTOUT (11HHELLO WORLD, 11) STOP END C SUBROUTINE WRTOUT (IARRAY, NCHRS) C INTEGER IARRAY(1) [FORTRAN 66 did not have a way to indicate a variable-sized array. So a '1' was typically used to indicate that the size is unknown.] INTEGER NCHRS C INTEGER ICPW DATA ICPW/4/ [Four characters per word.] INTEGER I, NWRDS C NWRDS = (NCHRS + ICPW - 1) /ICPW WRITE (6,100) (IARRAY(I), I=1,NWRDS) RETURN 100 FORMAT (100A4) [A count of 100 is a 'large enough' value that any reasonable number of characters can be written. Also note that four characters per word is hard-coded here too.] 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:

C PROGRAM HELLO3 WRITE (6,100) STOP 100 FORMAT (11HHELLO WORLD) END

One of the most surprising features (only for newbies, of course) 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:

C PROGRAM WHAT1 READ (5,100) WRITE (6,100) STOP 100 FORMAT (11HHELLO WORLD) END


Wikimedia Foundation. 2010.

Игры ⚽ Нужен реферат?

Look at other dictionaries:

  • Herman Hollerith — Infobox Person name = Herman Hollerith caption = birth date = birth date|1860|2|29|mf=y birth place = Buffalo, New York death date = Death date and age|1929|11|17|1860|2|29 death place = Washington, DC occupation = Statistician, inventor,… …   Wikipedia

  • Fortran — Infobox programming language name = Fortran caption = The Fortran Automatic Coding System for the IBM 704 (October 15, 1956), the first Programmer s Reference Manual for Fortran paradigm = multi paradigm: procedural, imperative, structured,… …   Wikipedia

  • History of computing hardware — Computing hardware is a platform for information processing (block diagram) The history of computing hardware is the record of the ongoing effort to make computer hardware faster, cheaper, and capable of storing more data. Computing hardware… …   Wikipedia

  • Timeline of computing hardware 2400 BC–1949 — History of computing Hardware before 1960 Hardware 1960s to present Hardware in Soviet Bloc countries Artificial intelligence Computer science Operating systems Programming languages …   Wikipedia

  • Plugboard — This article is about plugboards, or control panels, in unit record machines, cypher machines and early computers. For other uses, see plug board (disambiguation). IBM 402 Accounting Machine control panel[1] wiring. This board was labeled profit… …   Wikipedia

  • Key punch — A key punch is a device for entering data into punched cards by precisely punching holes at locations designated by the keys struck by the operator. Early keypunches were manual devices. Later keypunches were mechanized, often resembled a small… …   Wikipedia

  • Phonograph — Turntable redirects here. For other uses, see Turntable (disambiguation). Edison cylinder phonograph ca. 1899 …   Wikipedia

  • MACHINISME — On appelle «machinisme» un ensemble de conceptions et de pratiques nées de la prolifération des machines de production, elles mêmes produites, et «mécanisme» certaines conceptions scientifiques ou philosophiques qu’on a tirées depuis bien… …   Encyclopédie Universelle

  • Cryptanalysis of the Enigma — enabled the western Allies in World War II to read substantial amounts of secret Morse coded radio communications of the Axis powers that had been enciphered using Enigma machines. This yielded military intelligence which, along with that from… …   Wikipedia

  • 1924 — Portal Geschichte | Portal Biografien | Aktuelle Ereignisse | Jahreskalender ◄ | 19. Jahrhundert | 20. Jahrhundert | 21. Jahrhundert   ◄ | 1890er | 1900er | 1910er | 1920er | 1930er | 1940er | 1950er | ► ◄◄ | ◄ | 1920 | 1921 | 1922 | 1923 |… …   Deutsch Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”