4.8.2 · HinglishNumerical Methods

IEEE 754 floating-point standard — significant bits, special values

1,686 words8 min readRead in English

4.8.2 · Maths › Numerical Methods


KYA store ho raha hai?

32-bit (single precision) aur 64-bit (double precision) layouts:

Format Total bits Sign Exponent Fraction Bias
single 32 1 8 23 127
double 64 1 11 52 1023
Figure — IEEE 754 floating-point standard — significant bits, special values

Bits se number KAISE banta hai (derivation scratch se)

Step 1 — Binary mein Normalize karo. Koi bhi nonzero real number, binary scientific notation mein is tarah dikhai deta hai: Ye step kyun? Base 2 mein ek normalized number ka leading digit hamesha 1 hota hai (ye 0 nahi ho sakta, warna ye leading digit nahi hota). To wo bit humein free milti hai — ye implicit hoti hai ("hidden bit").

Step 2 — Sirf fraction store karo. Kyunki leading implied hai, hum sirf store karte hain. To significand hai Ye step kyun? Hidden ko store karna ek bit waste karta, aur precision ka ek free bit milta hai: 23 store kiye hue fraction bits effectively 24 significant bits ki tarah behave karte hain.

Step 3 — Exponent ko bias karo. Exponents negative () ya positive () ho sakte hain. Exponent ke liye sign rakhne ki jagah, hum store karte hain jahan = exponent bits ki sankhya. Kyun? Ek plain unsigned se simple integer comparison se floats ko sahi sort kiya ja sakta hai, aur all-0 aur all-1 patterns reserved rehte hain special meanings ke liye.


Significant bits & precision


Special values (reserved exponent patterns)

All-0 aur all-1 exponent fields ordinary numbers nahi hain:

field fraction meaning
all 0 (signed zero)
all 0 subnormal (denormal) number, koi hidden 1 nahi:
(single) any normal number (upar wala formula)
all 1
all 1 NaN (Not a Number)

Worked examples


Common mistakes (steel-manned)


Recall Feynman: 12-saal ke bacche ko samjhao

Socho tumhare paas ek chhoti card hai jisme sirf 7 digits likh sakte ho, lekin saath mein ek chhota "dot shift karo" note bhi milta hai. To tum likhte ho aur ek note "dot ko 23 jagah right shift karo" likhte ho ek bade number ke liye, ya "left shift karo" ek chhote number ke liye. Card mantissa hai, note exponent hai, aur ek box sign hai. Kyunki card mein sirf kuch digits hain, kuch numbers jaise perfectly fit nahi hote — tumhe sabse close card milti hai jo tum likh sako. Do special notes save hote hain: ek kehta hai "ye itna bada hai ki basically infinity hai," aur ek kehta hai "ye koi real number hi nahi hai" (jaise zero se divide karna).


Flashcards

IEEE 754 single-precision bit split (sign/exp/frac)?
1 / 8 / 23 bits
IEEE 754 double-precision bit split?
1 / 11 / 52 bits
Value formula for a normal float?
Bias for single and double precision?
127 and 1023 (i.e. )
What is the "hidden bit"?
The implicit leading 1 of a normalized significand, not stored
Effective significant bits in single precision?
24 (23 stored + 1 hidden) ≈ 7 decimal digits
Definition of machine epsilon?
Gap between 1.0 and next float,
Machine epsilon (single, double)?
,
How is encoded?
Exponent all 1s, fraction = 0
How is NaN encoded?
Exponent all 1s, fraction
How is a subnormal encoded and valued?
Exp all 0s, :
Why do subnormals exist?
Gradual underflow — fill the gap between smallest normal and 0
Quick test for NaN in code?
x != x is true only for NaN
Why isn't 0.1 exact?
Its binary expansion repeats forever; 5 is not a power of 2
Decimal digits from p bits?

Connections

Concept Map

solved by

stores as

formula

Step 1

leading 1 always

Step 2

gains free bit

Step 3

reserves patterns

p times log10 2

defines

two layouts

Finite bits vs infinite reals

IEEE 754 standard

Sign + Mantissa + Exponent

x = -1^s times m times 2^e

Normalize in binary

Hidden bit implicit

Significand 1.f

24 or 53 significant bits

Biased exponent E plus bias

Special values

Decimal digits precision

Machine epsilon 2^-(p-1)

Single 32-bit / Double 64-bit