Skip to content
This repository has been archived by the owner on Aug 31, 2021. It is now read-only.

Latest commit

 

History

History
74 lines (53 loc) · 3.69 KB

floating_point_number.md

File metadata and controls

74 lines (53 loc) · 3.69 KB

Floating-point number

The Concept

A floating point number is a real number, which differ from whole numbers in that a real number also allows for exponent digits.

Programming languages may name their floating point type to the amount of precision they can hold, whereas the following is based on the IEEE 754 standard:

What to cover

A student may have no understanding of floating point numbers as more than numbers with decimal points.

  • Explain that a floating point number is not just a number with a decimal place.
  • Explain what floating point types are used in your langauge, and when to use them.
  • Ensure that type conversions are understood if appropriate (e.g. rounding, precision-changing)
  • Ensure that students know how to compare numbers to each other.

Useful links

Exercises

Production Line Analysis

This exercise asks students to write code to analyse the production of an assembly line. The reference implementation (C#) teaches:

  • Arithmetic
  • Comparing numbers
  • Converting between integers and floating point numbers.
  • Conditionals

Implementations

Track Exercise Changes
C# cars-assemble None
F# cars-assemble None
Go numbers None

Savings Accounts

This exercise calculates interest on savings accounts. The reference implementation (C#) teaches:

  • Rounding
  • The importance of different precisions, using integers, 4 byte floating point numbers and 16 byte floating point numbers
  • Basic loops

Implementations

Track Exercise Changes
C# interest-is-interesting None
F# interest-is-interesting Replaced third task that used while loop with task that uses an int/double/decimal combination.