✕ Close

Week 15 · 15.1 · Mon, Nov 9 · The Bigger Picture: ACT-style reading

The Wrong-Size Box: From Ariane 5 to Java's Types

1 This section explains why the kind of value a box holds matters, from a rocket launched in 1996 to the typed boxes that every Java program uses.

A Number Too Big for Its Box

2 On June 4, 1996, the first Ariane 5 rocket was launched on its maiden flight. The rocket carried the four satellites of a European Space Agency science mission called Cluster. About 40 seconds after the flight sequence began, the rocket veered off its flight path, broke up and exploded, and the four satellites were lost with it.

3 An inquiry board chaired by Professor Lions reported the cause in July 1996. The rocket's inertial reference system, the unit that measured the rocket's position and motion, ran software that converted one number from one form to another. The number, called the horizontal bias, was stored as a 64-bit floating-point value, a form that can hold very large numbers and numbers with a decimal part. The software converted it into a 16-bit signed integer, a much smaller box that holds only whole numbers. During the flight, the value of the horizontal bias was much higher than expected, so it did not fit, and the conversion failed with an error. The backup system ran the same software, and it had already stopped for the same reason about 72 milliseconds earlier.

4 The board found that this software had been designed for Ariane 4, an earlier rocket, and that Ariane 5 built up horizontal speed about five times as fast. The software protected some of its conversions, but three values, including the horizontal bias, were left unprotected. The part of the software that failed served no purpose after lift-off. The satellites were rebuilt, and Cluster was launched again in 2000.

Boxes With Types

5 Java treats every box in a program as having a type. A variable is a named box that holds a value, and a data type decides which values the box may contain and what can be done with them. Before a variable can be used, a Java program must declare it, which means stating its type and its name, as in int gear = 1;. Oracle's Java tutorial calls Java "statically-typed" for this reason.

6 Four types appear on today's bench. An int holds whole numbers, from about negative 2.1 billion to about positive 2.1 billion. A double holds numbers with a decimal part, and it is the usual choice for decimal values. A boolean holds only true or false. A String holds text, written inside double quotation marks. Figure 1 sets the box in Ariane 5's software beside four of Java's typed boxes.

7 A box keeps its type for the whole program. After a variable has been declared, a line such as laps = 5; stores a new value in the same box, and that line has no type in front because the box already exists. Writing the type a second time, as in int laps = 5;, would declare a second box with the same name, and Java does not allow that.

When a Value Does Not Fit

8 Java's compiler checks every value against the type of its box before the program runs. A whole number fits in a double box, so double d = 7; stores 7.0. The reverse is refused. The line int score = 7.5; does not compile, and the compiler reports "possible lossy conversion from double to int." The Java Language Specification explains that a conversion like this one "may lose information," so Java will not do it on its own.

1double d = 7;
2System.out.println(d);
7.0

9 Java also has a 16-bit whole-number type, short, which holds values from negative 32,768 to positive 32,767, the same size of box as the one in Ariane 5's software. Today's question asks what a language should do when a value does not fit its box. In Java, the compiler refuses a value that could be cut short, so the program never runs with it, and the programmer has to choose a box of the right type. On today's bench, each value is matched to its type, each box is traced line by line and each line that does not compile is found.

Summary

10 In 1996, a number too big for its box helped destroy Ariane 5 on its first flight. In Java, every variable is declared with a data type, and the type decides what the box can hold: int for whole numbers, double for decimals, boolean for true or false and String for text in quotation marks. A box keeps its type, and the compiler refuses a value that does not fit.

Sources: European Space Agency, Ariane 501: Presentation of Inquiry Board report (1996) and Celebrating rebirth (2015); J. L. Lions and others, Ariane 5 Flight 501 Failure: Report by the Inquiry Board (1996); Oracle, The Java Tutorials: Primitive Data Types and Variables; Oracle, The Java Language Specification, Java SE 21 Edition, Chapter 5; course JDK runs.

Figure 1. In 1996 a 64-bit value did not fit a 16-bit box in Ariane 5's software; in Java every box has a type that decides what fits; and the compiler refuses a value that does not fit.
ACT-style reading · 9 questions

Read the passage on the left. Answer each question by clicking a choice: the right answer turns green, and a wrong one tells you why. Questions point to paragraph numbers, as on the ACT.

1. Main idea

The main purpose of the passage is to:

2. Detail

According to paragraph 3, what did the software try to do with the horizontal bias?

3. Words in context

As it is used in paragraph 4 ("three values, including the horizontal bias, were left unprotected"), the word unprotected most nearly means:

4. Cause and effect

According to paragraphs 3 and 4, why did the horizontal bias not fit its box on Ariane 5 when the same software had worked on Ariane 4?

5. Inference

Based on paragraph 3, why did having a backup system not save the flight?

6. Detail

According to paragraph 5, what does it mean to declare a variable in Java?

7. Compare

According to paragraph 6, how does a double differ from an int?

8. Cause and effect

According to paragraph 8, why does double d = 7; compile while int score = 7.5; does not?

9. Author's claim

Which sentence from the passage best answers what Java does when a value does not fit its box?