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:
- Half (occupying 16 bits)
- Single (occupying 32 bits)
- Double (occupying 64 bits)
- Quadruple (occupying 128 bits)
- Octuple (occupying 256 bits)
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.
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
| Track | Exercise | Changes |
|---|---|---|
| C# | cars-assemble | None |
| F# | cars-assemble | None |
| Go | numbers | None |
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
| 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. |