Digital computation is central to almost all scientific endeavors and has become integral to university physics education. Students collect experimental data using digital devices, process data using spreadsheets and graphical software, and develop scientific programming skills for modeling, simulation, and computational work. Issues associated with the floating-point representation of numbers are rarely explored. In this article, problems of floating point are divided into three categories: significant-figure limits, propagation of floating-point representation error, and rounding. For each category, examples are presented of unexpected ways, in which the digital representation of floating-point numbers can impact the veracity of scientific results. These examples cover aspects of classical dynamics, numerical integration, cellular automata, statistical analysis, and digital timing. Suggestions are made for curriculum enhancement and project-style investigations that reinforce the issues covered at a level suitable for physics undergraduate students.

1.
Institute of Electrical and Electronics Engineers, Computer Society, Standards Committee, and David Stevenson
,
IEEE Standard for Binary Floating-Point Arithmetic
(
IEEE
,
New York
,
1985
).
2.
J. H.
Wilkinson
, in
Rounding Errors in Algebraic Processes
, edited by
A. A.
Grau
(
Society for Industrial and Applied Mathematics
,
Pennsylvania
,
1966
).
3.
James H.
Wilkinson
, “
Error analysis of floating-point computation
,”
Numer. Math.
2
(
1
),
319
340
(
1960
).
4.
Rubin H.
Landau
,
Jose
Paez
,
Manuel José Páez
Mejía
, and
Cristian C.
Bordeianu
,
A Survey of Computational Physics: Introductory Computational Science
(
Princeton U. P
.,
Princeton
,
2008
).
5.
Linda
Grandell
,
Mia
Peltomäki
,
Ralph-Johan
Back
, and
Tapio
Salakoski
, “Why complicate things? Introducing programming in high school using Python
,” in
Proceedings of the 8th Australasian Conference on Computing Education
(
2006
), Vol.
52
, pp.
71
80
.
6.
Athanassios
Jimoyiannis
and
Vassilis
Komis
, “
Computer simulations in physics teaching and learning: A case study on students' understanding of trajectory motion
,”
Comput. Educ.
36
(
2
),
183
204
(
2001
).
7.
Peter
Junglas
, “
Simulation programs for teaching thermodynamics
,”
Global J. Eng. Educ.
10
(
2
),
175
180
(
2006
), available at <http://www.wiete.com.au/journals/GJEE/Publish/Vol.10,%20No.2/Junglas.pdf>.
8.
Rubin
Landau
, “
Simulation programs for teaching thermodynamics
,”
Comput. Phys. Commun.
177
(
1–2
),
191
194
(
2007
).
9.
Elvira
Martinez
,
Mercedes
Florez
, and
Jose
Amaya
, “
Simulations as a new physics teaching tool
,”
Comput. Appl. Eng. Educ..
18
(
4
),
757
761
(
2010
).
10.
Jesse M.
Kinder
and
Philip
Nelson
,
A Student's Guide to Python for Physical Modeling: Updated Edition
(
Princeton U. P
.,
Princeton
,
2018
).
11.
Philip C.
Nelson
and
Tom
Dodson
, “A Student's Guide to Matlab for Physical Modeling,” Technical Report, 2018, available at <https://works.bepress.com/philip-c-nelson/104>.
12.
Claudio
Rebbi
, “
A project-oriented course in computational physics: Algorithms, parallel computing, and graphics
,”
Am. J. Phys.
76
(
4
),
314
320
(
2008
).
13.
Todd
Timberlake
and
Javier E.
Hasbun
, “
Computation in classical mechanics
,”
Am. J. Phys.
76
(
4
),
334
339
(
2008
).
14.
David M.
Cook
, “
Computation in undergraduate physics: The Lawrence approach
,”
Am. J. Phys.
76
(
4
),
321
326
(
2008
).
15.
Andy
Buffler
,
Seshini
Pillay
,
Fred
Lubben
, and
Roger
Fearick
, “
A model-based view of physics for computational activities in the introductory physics course
,”
Am. J. Phys.
76
(
4
),
431
437
(
2008
).
16.
Ruth
Chabay
and
Bruce
Sherwood
, “
Computational physics in the introductory calculus-based course
,”
Am. J. Phys.
76
(
4
),
307
313
(
2008
).
17.
See supplemental material at https://www.scitation.org/doi/suppl/10.1119/10.0003915 for the instructions provided to students, which are provided as a Word document, for all computer codes referred to, and for a video of the evolution of the “seed” object using the rules of the semi-classical game.
18.
Decimal fixed point and floating point arithmetic
” in The Python Standard Library, available at <https://docs.python.org/3/library/decimal.html> (accessed on February 2021).
19.
A summary of the many forms of Verlet integration algorithms may be found at the wikipedia site Verlet Integration
, available at <https://en.wikipedia.org/wiki/Verlet_integration> (accessed on February 2021).
20.
Milton
Abramowitz
and
Irene A.
Stegun
,
Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables
(
Dover Publications, Inc
.,
New York
,
2014
).
21.
I. S.
Gradshteyn
and
I. M.
Ryzhik
,
Table of Integrals, Series, and Products
, 8th ed., edited by
Daniel
Zwillinger
and
Victor
Moll
(
Elsevier
,
New York
,
2015
).
22.
Bruce M.
Boghosian
,
Peter V.
Coveney
, and
Hongyan
Wang
, “
A new pathology in the simulation of chaotic dynamical systems on digital computers
,”
Adv. Theory Simul.
2
(
12
),
1900125
(
2019
).
23.
Martin
Gardner
, “
Mathematical games - The fantastic combinations of John Conway's new solitaire game ‘life
,’”
Sci. Am.
223
,
120
123
(
1970
).
24.
Adrian P.
Flitney
and
Derek
Abbott
, “
A semi-quantum version of the game of life
,” in
Quantum Aspects of Life
(
World Scientific
,
Singapore
,
2008
), pp.
233
250
.
25.
David A.
Faux
,
Mayank
Shah
, and
Christopher
Knapp
, “
Games of life
,”
Am. J. Phys.
88
,
371
378
(
2020
).
26.
Apinya
Dhatsuwan
and
Monamorn
Precharattana
, “
BLOCKYLAND: A cellular automata-based game to enhance logical thinking
,”
Simul. Gaming
47
(
4
),
445
464
(
2016
).
27.
G.
Faraco
,
Pietro
Pantano
, and
Rocco
Servidio
, “
The use of cellular automata in the learning of emergence
,”
Comput. Educ.
47
(
3
),
280
297
(
2006
).
28.
Douglas N.
Arnold
, “The patriot missile failure” <http://www-users.math.umn.edu/∼arnold/disasters/patriot.html> (accessed on February 2021).
29.
David
Amos
, “How to round numbers in Python,” <realpython.com/python-rounding> (accessed on February
2021
).
30.
Python Documentation: The Python Tutorial 15, “
Floating point arithmetic: Issues and limitations
,” <https://docs.python.org/3/tutorial/floatingpoint.html> (accessed on February 2021).
31.
Jeff C.
Gust
,
Robert M.
Graham
, and
Michael A.
Lombardi
,
Stopwatches and Timer Calibrations
, NIST Recommended Practice Guide, 2009th ed. (
NIST
,
Maryland
,
2009
).
32.
Michael
Robbins
,
Electronic Clocks and Watches
(
Howard W. Sams Co
.,
Indianapolis, IN
,
1975
).
33.
J. R.
Vig
,
Stopwatches and Timer Calibrations
, NIST Recommended Practice Guide (
NIST
,
Maryland
,
1992
).
34.
Converting binary fields to time of day format, IBM Knowledge Center
, at <https://www.ibm.com/support/knowledgecenter/en/SSLTBW_2.1.0/com.ibm.zos.v2r1.ieag200/cnvttime.htm> (accessed on February 2021).
35.
David
Faux
and
Janet
Godolphin
, “
Manual timing in physics experiments: Error and uncertainty
,”
Am. J. Phys.
87
(
2
),
110
115
(
2019
).
36.
David
Faux
and
Janet
Godolphin
, “
The floating point: Rounding error in timing devices
,”
Am. J. Phys.
(
2021
).

Supplementary Material

AAPT members receive access to the American Journal of Physics and The Physics Teacher as a member benefit. To learn more about this member benefit and becoming an AAPT member, visit the Joining AAPT page.