ArticleslgStudy

mathematics

Line number

Line number is a mathematics 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 Line number rather than just read about it. In short: In computing, a line number is a method used to specify a particular sequence of characters in a text file. The most common method of assigning numbers to lines is to assign every line a unique number, starting at 1 for the first line, and incrementing by 1 for each successive line.

Key takeaways

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

Reference excerpt

In computing, a line number is a method used to specify a particular sequence of characters in a text file. The most common method of assigning numbers to lines is to assign every line a unique number, starting at 1 for the first line, and incrementing by 1 for each successive line. In the C programming language the line number of a source code line is one greater than the number of new-line characters read or introduced up to that point. Programmers could also assign line numbers to statements in older programming languages, such as Fortran, JOSS, and BASIC. In Fortran, not every statement needed a line number, and line numbers did not have to be in sequential order. The purpose of line numbers was for branching and for reference by formatting statements. Both JOSS and BASIC made line numbers a required element of syntax. The primary reason for this is that most operating systems at the time lacked interactive text editors; since the programmer's interface was usually limited to a line editor, line numbers provided a mechanism by which specific lines in the source code could be referenced for editing, and by which the programmer could insert a new line at a specific point. Line numbers also provided a convenient means of distinguishing between code to be entered into the program and direct mode commands to be executed immediately when entered by the user (which do not have line numbers). Largely due to the prevalence of interactive text editing in modern operating systems, line numbers are not a feature of most programming languages, even modern Fortran and Basic.

History

FORTRAN In Fortran, as first specified in 1956, line numbers were used to define input/output patterns, to specify statements to be repeated, and for conditional branching. For example:

Like assembler language before it, Fortran did not assume every line needed a label (line number, in this case). Only statements referenced elsewhere required a line number:

Line 1 specifies a format pattern for input; the READ command in line 2 and the later PRINT command both reference this line. The DO loop executes line 3. The arithmetic IF statement branches to line 4 on a negative value, line 3 on zero, and again line 3 on a positive value. While the line numbers are sequential in this example, in the very first "complete but simple [Fortran] program" published the line numbers are in the sequence 1, 5, 30, 10, 20, 2. Line numbers could also be assigned to fixed-point variables (e.g., ASSIGN i TO n) for referencing in subsequent assigned GO TO statements (e.g., GO TO n,(n1,n2,...nm)).

COBOL In COBOL, line numbers were specified in the first six characters (the sequence number area) of punched cards. This was originally used for facilitating mechanical card sorting to assure intended program code sequence after manual handling. The line numbers were actually ignored by the compiler.

DOPE In 1962, DOPE (Dartmouth Oversimplified Programming Experiment) became one of the first programming languages to require a line number for every statement and to use sequential ordering of line numbers. Line numbers were specified as destinations for two commands, C (Compare operation, an arithmetic IF) and T (To operation, a GO TO).

JOSS In 1963, JOSS independently made line numbers mandatory for every statement in a program and ordered lines in sequential order. JOSS introduced the idea of a single command line editor that worked both as an interactive language and a program editor. Commands that were typed without a line number were executed immediately, in what JOSS referred to as "direct mode". If the same line was prefixed with a line number, it was instead copied into the program code storage area, which JOSS called "indirect mode". Unlike FORTRAN before it or BASIC after it, JOSS required line numbers to be fixed-point numbers consisting of a pair of two-digit integers separated by a period (e.g., 1.1). The portion of the line number to the left of the period is known as the "page" or "part", while the portion to the right is known as the "line"; for example, the line number 10.12 refers to page 10, line 12. Branches can target either a page or a line within a page. When the later format is used, the combined page and line is known as a "step". Pages are used to define subroutines, which return when the next line is on a different page. For instance, if a subroutine for calculating the square root of a number is in page 3, one might have three lines of code 3.1, 3.2 and 3.3, and it would be called using Do part 3. The code would return to the statement after the Do when it reaches the next line on a different page, for instance, 4.1. There is no need for the equivalent of a RETURN at the end, although if an early return is required, Done accomplishes this. Example:

*Routine to ask the user for a positive value and repeat until it gets one 01.10 Demand X as "Enter a positive value greater than zero". 01.20 Done if X>0. 01.30 To step 1.1

BASIC Introduced in 1964, Dartmouth BASIC adopted mandatory line numbers, as in JOSS, but made them integers, as in FORTRAN. As defined initially, BASIC only used line numbers for GOTO and GOSUB (go to subroutine, then return). Some Tiny BASIC implementations supported numeric expressions instead of constants, while switch statements were present in different dialects (ON GOTO; ON GOSUB; ON ERROR GOTO). Line numbers were rarely used elsewhere. One exception was allowing the pointer used by READ (which iterated through DATA statements) to be set to a specific line number using RESTORE.

In the first editions of Dartmouth BASIC, THEN could only be followed by a line number (for an implied GOTO), not - as in later implementations - by a statement. The range of valid line numbers varied widely from implementation to implementation, depending on the representation used to store the binary equivalent of the line number (one or two bytes; signed or unsigned). While Dartmouth BASIC supported 1 to 99999, the typical microcomputer implementation supported 1 to 32767 (a signed 16-bit word).

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with Line number

Start with the simplest possible case. Write down what Line number claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In mathematics, 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 Line number 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 Line number 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 Line number

In research
Line number appears in mathematics 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 Line number 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
Line number is common in secondary-school and first-year university syllabi. It links to neighbouring topics Source code, Text editor features, so understanding it makes those chapters shorter.
In everyday life
Look for Line number 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.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Line number” →

How to study Line number in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Line number 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 Line number out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Line number in simple terms?

In computing, a line number is a method used to specify a particular sequence of characters in a text file. The most common method of assigning numbers to lines is to assign every line a unique number, starting at 1 for the first line, and incrementing by 1 for each successive line.

Why does Line number matter?

Because it connects several mathematics 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 Line number?

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 Line number.

Tags

  • Source code
  • Text editor features

Keep exploring