#separator:tab
#html:true
#notetype:Basic
#tags column:3
#deck:cracked.guide::TAOCP Vol 2::4.2.1 Single-Precision Calculations
#columns:Front	Back	Tags
TAOCP §4.2.1 Single-Precision Calculations: what does it cover?	How floating-point numbers are stored (sign, exponent, fraction) and the algorithms for add, subtract, multiply and divide, including normalization and rounding. Knuth uses his own floating format on MIX, not IEEE 754.	cracked.guide cracked.guide::phase::taocp-2 cracked.guide::section::4.2.1 cracked.guide::kind::about
TAOCP §4.2.1: why does it matter?	Floats are in almost every program and most programmers have only a vague model of them. Implementing float addition yourself is the fastest way to understand why 0.1 + 0.2 is not 0.3.	cracked.guide cracked.guide::phase::taocp-2 cracked.guide::section::4.2.1 cracked.guide::kind::why
TAOCP §4.2.1, a common trap: “Assuming Knuth's format matches IEEE 754.” What's the catch?	The ideas transfer, the bit layouts do not.	cracked.guide cracked.guide::phase::taocp-2 cracked.guide::section::4.2.1 cracked.guide::kind::trap
TAOCP §4.2.1, exercise 1 (rated 10): what is it asking?	Encode two physical constants in a toy floating-point format.	cracked.guide cracked.guide::phase::taocp-2 cracked.guide::section::4.2.1 cracked.guide::kind::exercise
TAOCP §4.2.1, exercise 3 (rated 11): what is it asking?	The hidden leading bit trick. IEEE 754 uses it.	cracked.guide cracked.guide::phase::taocp-2 cracked.guide::section::4.2.1 cracked.guide::kind::exercise
TAOCP §4.2.1, exercise 4 (rated 16): what is it asking?	Trace floating addition on concrete inputs, including a catastrophic one.	cracked.guide cracked.guide::phase::taocp-2 cracked.guide::section::4.2.1 cracked.guide::kind::exercise
TAOCP §4.2.1, exercise 10 (rated 12): what is it asking?	Find a case where rounding pushes the fraction past 1 during addition.	cracked.guide cracked.guide::phase::taocp-2 cracked.guide::section::4.2.1 cracked.guide::kind::exercise
TAOCP §4.2.1, exercise 16 (rated HM21): what is it asking?	Divide complex numbers without overflow. Smith's algorithm is still used today.	cracked.guide cracked.guide::phase::taocp-2 cracked.guide::section::4.2.1 cracked.guide::kind::exercise
TAOCP §4.2.1, exercise 15 (rated 28, recommended): what is it asking?	Write the fractional-part routine and handle tiny and huge inputs carefully.	cracked.guide cracked.guide::phase::taocp-2 cracked.guide::section::4.2.1 cracked.guide::kind::exercise
TAOCP §4.2.1, exercise 13 (rated 30): what is it asking?	Directed rounding for interval arithmetic.	cracked.guide cracked.guide::phase::taocp-2 cracked.guide::section::4.2.1 cracked.guide::kind::exercise
TAOCP §4.2.1, exercise 12 (rated M25): what is it asking?	Prove that rounding overflow cannot happen when normalizing a quotient. The stretch.	cracked.guide cracked.guide::phase::taocp-2 cracked.guide::section::4.2.1 cracked.guide::kind::exercise
TAOCP §4.2.1: how many exercises, and how are they rated?	19 exercises, rated 10 to 40.	cracked.guide cracked.guide::phase::taocp-2 cracked.guide::section::4.2.1 cracked.guide::kind::exercises
TAOCP §4.2.1: what should you be comfortable with first?	<ul><li>4.1 Positional Number Systems</li><li>Basic MIX</li></ul>	cracked.guide cracked.guide::phase::taocp-2 cracked.guide::section::4.2.1 cracked.guide::kind::prereqs
TAOCP §4.2.1: how should you work through it?	Read alongside the IEEE 754 Wikipedia page so you can map Knuth's concepts to real hardware. Implement float addition on a toy format (say 8-bit exponent and 16-bit fraction) in C using integers.	cracked.guide cracked.guide::phase::taocp-2 cracked.guide::section::4.2.1 cracked.guide::kind::approach
