Inform 7 Home Page / Documentation


Chapter 15: Numbers and Equations

§15.1. How do we measure things?; §15.2. Numbers and real numbers; §15.3. Real number conversions; §15.4. Printing real numbers; §15.5. Arithmetic; §15.6. Powers and logarithms; §15.7. Trigonometry; §15.8. Units; §15.9. Multiple notations; §15.10. Scaling and equivalents; §15.11. Named notations; §15.12. Making the verb "to weigh"; §15.13. The Metric Units extension; §15.14. Notations including more than one number; §15.15. The parts of a number specification; §15.16. Understanding specified numbers; §15.17. Totals; §15.18. Equations; §15.19. Arithmetic with units; §15.20. Multiplication of units

arrow-up-left.png Contents of Writing with Inform
arrow-left.png Chapter 14: Adaptive Text and Responses
arrow-right.png Chapter 16: Tables
arrow-down-right.png Indexes of the examples

§15.1. How do we measure things?

In a poem, or in a novel, exact scientific measurements are not the point. So a writer who wants to set up ways to describe the sky at different times might go for something like this:

The sky can be cadmium, mackerel, overcast or cornflower.

And nobody is interested in the sun angle, the percentage of cloud cover, or any of the other numbers behind all of this. Similarly, if we walk into a familiar office which has been disturbed, we might well say "Look! The filing cabinet is in the middle of the floor." We are not likely to exclaim "Look! The filing cabinet is 1.2m from the east wall and 2.1m from the north wall."

But some writers of interactive fiction do like to make use of physical realism. For instance, it's easier to forbid a bulky object being taken through a narrow doorway if there is a way to measure and compare sizes.

Most computer programs write numbers in the same way, whatever they're used for. But human beings don't. If someone says "How far is Duluth?", we're more likely to say "100 miles" than just "100". This is a useful feature of natural language, because it means we always know how to translate that number into reality - it's 100 miles, not 100 km, or 100 inches; and it's definitely a distance, not 100 apples or 100 kilograms.

Inform lets us use plain numbers if we want to, but it also allows us to create numerical kinds of value:

A distance is a kind of value. 5 miles specifies a distance.

That kind of definition, and the consequences, will be the subject of this chapter. But we will first look a little harder at the two numerical kinds of value we get for free: "number" and "real number".


arrow-up.png Start of Chapter 15: Numbers and Equations
arrow-left.png Back to Chapter 14: Adaptive Text and Responses: §14.12. The RESPONSES testing command
arrow-right.png Onward to §15.2. Numbers and real numbers