Difference between revisions of "W2031 Designing a Floating Point Type"

From Coder Merlin
 
(3 intermediate revisions by the same user not shown)
Line 6: Line 6:
== Key Concepts ==
== Key Concepts ==
== Exercises ==
== Exercises ==
* Design a '''struct''' whose member properties may only be of type '''Int'''.
{{W2031-Exercises}}
* Define initializers:
 
** init(_ d:Double)
** init(_ n:Int)
* Define operations for addition, subtraction, multiplication, and division.
== References ==
== References ==
* [https://en.wikipedia.org/wiki/Double-precision_floating-point_format Double Precision Floating Point Format] (Wikipedia)
* [http://bartaz.github.io/ieee754-visualization/ IEEE754 Visualization] (Bartaz)
* [https://www.h-schmidt.net/FloatConverter/IEEE754.html IEEE754 Floating Point Converter] (Schmidt)
* [https://www.h-schmidt.net/FloatConverter/IEEE754.html Converting to IEEE754 Form] (IA State)
* [https://github.com/jwiegley/gdtoa Conversion Library] (David M. Gay)

Latest revision as of 09:09, 13 November 2020

Within these castle walls be forged Mavens of Computer Science ...
— Merlin, The Coder
Evergreen Point Floating Bridge

Prerequisites[edit]

Background[edit]

Introduction[edit]

Topic Headers[edit]

Key Concepts[edit]

Exercises[edit]

ExercisesExercisesIcon.png
  • Design a struct named Real whose member properties may only be of type Int or Bool.
  • Define initializers:
    • init(_ d:Double)
    • init(_ n:Int)
  • Define functions for addition, subtraction, multiplication, and division.
    • All such functions should take the form: func operationName(_ other:Real) -> Real
    • These functions should be named add, subtract, multiply, and divide

References[edit]