ArticleslgStudy

computer science

Single-precision floating-point format

Single-precision floating-point format is a computer science 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 Single-precision floating-point format rather than just read about it. In short: Single-precision floating-point format (sometimes called FP32, float32, or float) is a computer number format, usually occupying 32 bits in computer memory; it represents a wide range of numeric values by using a floating radix point. A floating-point variable can represent a wider range of numbers than a fixed-point variable of the same bit width at the cost of precision.

Single-precision floating-point format — main illustration
Single-precision floating-point format — illustration

Key takeaways

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

Reference excerpt

Single-precision floating-point format (sometimes called FP32, float32, or float) is a computer number format, usually occupying 32 bits in computer memory; it represents a wide range of numeric values by using a floating radix point. A floating-point variable can represent a wider range of numbers than a fixed-point variable of the same bit width at the cost of precision. A signed 32-bit integer variable has a maximum value of 231 − 1 = 2,147,483,647, whereas an IEEE 754 32-bit base-2 floating-point variable has a maximum finite value of (2 − 2−23) × 2127 ≈ 3.4028235 × 1038. All integers with seven or fewer decimal digits, and any 2n for a whole number −149 ≤ n ≤ 127, can be converted exactly into an IEEE 754 single-precision floating-point value. In the IEEE 754 standard, the 32-bit base-2 format is officially referred to as binary32; it was called single in IEEE 754-1985. IEEE 754 specifies additional floating-point types, such as 64-bit base-2 double precision and, more recently, base-10 representations. One of the first programming languages to provide single- and double-precision floating-point data types was Fortran. Before the widespread adoption of IEEE 754-1985, the representation and properties of floating-point data types depended on the computer manufacturer and computer model, and upon decisions made by programming-language designers. E.g., GW-BASIC's single-precision data type was the 32-bit MBF floating-point format. Single precision is termed SINGLE-FLOAT in Common Lisp; float binary(p) with p≤21, float decimal(p) with the maximum value of p depending on whether the DFP (IEEE 754 DFP) attribute applies, in PL/I; float in C with IEEE 754 support, C++ (if it is in C), C# and Java; Float in Haskell and Swift; and Single in Object Pascal (Delphi), Visual Basic, and MATLAB. However, float in Python, Ruby, PHP, and OCaml and single in versions of Octave before 3.2 refer to double-precision numbers. In most implementations of PostScript, and some embedded systems, the only supported precision is single.

IEEE 754 standard: binary32 The IEEE 754 standard specifies a binary32 as having:

Sign bit: 1 bit Exponent width: 8 bits Significand precision: 24 bits (23 explicitly stored) This gives from 6 to 9 significant decimal digits precision. If a decimal string with at most 6 significant digits is converted to the IEEE 754 single-precision format, giving a normal number, and then converted back to a decimal string with the same number of digits, the final result should match the original string. If an IEEE 754 single-precision number is converted to a decimal string with at least 9 significant digits, and then converted back to single-precision representation, the final result must match the original number. The sign bit determines the sign of the number, which is the sign of the significand as well. "1" stands for negative. The exponent field is an 8-bit unsigned integer from 0 to 255, in biased form: a value of 127 represents the actual exponent zero. Exponents range from −126 to +127 (thus 1 to 254 in the exponent field), because the biased exponent values 0 (all 0s) and 255 (all 1s) are reserved for special numbers (subnormal numbers, signed zeros, infinities, and NaNs). The true significand of normal numbers includes 23 fraction bits to the right of the binary point and an implicit leading bit (to the left of the binary point) with value 1. Subnormal numbers and zeros (which are the floating-point numbers smaller in magnitude than the least positive normal number) are represented with the biased exponent value 0, giving the implicit leading bit the value 0. Thus only 23 fraction bits of the significand appear in the memory format, but the total precision is 24 bits (equivalent to log10(224) ≈ 7.225 decimal digits) for normal values; subnormals have gracefully degrading precision down to 1 bit for the smallest non-zero value. The bits are laid out as follows:

The real value assumed by a given 32-bit binary32 data with a given sign, biased exponent E (the 8-bit unsigned integer), and a 23-bit fraction is

( − 1 ) b 31 × 2 ( b 30 b 29 … b 23 ) 2 − 127 × ( 1. b 22 b 21 … b 0 ) 2 {\displaystyle (-1)^{b_{31}}\times 2^{(b_{30}b_{29}\dots b_{23})_{2}-127}\times (1.b_{22}b_{21}\dots b_{0})_{2}} , which yields

value = ( − 1 ) sign × 2 ( E − 127 ) × ( 1 + ∑ i = 1 23 b 23 − i 2 − i ) . {\displaystyle {\text{value}}=(-1)^{\text{sign}}\times 2^{(E-127)}\times \left(1+\sum _{i=1}^{23}b_{23-i}2^{-i}\right).}

In this example:

sign = b 31 = 0 {\displaystyle {\text{sign}}=b_{31}=0} ,

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with Single-precision floating-point format

Start with the simplest possible case. Write down what Single-precision floating-point format claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, 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 Single-precision floating-point format 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 Single-precision floating-point format 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 Single-precision floating-point format

In research
Single-precision floating-point format appears in computer science 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 Single-precision floating-point format 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
Single-precision floating-point format is common in secondary-school and first-year university syllabi. It links to neighbouring topics Binary arithmetic, Computer arithmetic, Floating point types, so understanding it makes those chapters shorter.
In everyday life
Look for Single-precision floating-point format 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.

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Single-precision floating-point format in 20 minutes

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

Frequently asked questions

What is Single-precision floating-point format in simple terms?

Single-precision floating-point format (sometimes called FP32, float32, or float) is a computer number format, usually occupying 32 bits in computer memory; it represents a wide range of numeric values by using a floating radix point. A floating-point variable can represent a wider range of numbers…

Why does Single-precision floating-point format matter?

Because it connects several computer science 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 Single-precision floating-point format?

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 Single-precision floating-point format.

Tags

  • Binary arithmetic
  • Computer arithmetic
  • Floating point types

Keep exploring