tutor.org.in

Free preview · Reading · 1 h

Binary data: integers, floating point and text

Computing Systems · Data and digital logic

In this lesson

  • Use two’s complement and detect overflow
  • Explain IEEE 754 floating point and its rounding

Explanation

Signed integers use two’s complement: an 8-bit byte holds −128 to 127, and adding past the range wraps around. Floating-point numbers store a sign, exponent and fraction, so most decimal fractions are approximations. Text is stored as Unicode code points, usually encoded as UTF-8.

Worked example

−5 in 8-bit two’s complement: invert 00000101 → 11111010, add 1 → 11111011. In Python, 0.1 + 0.2 == 0.3 is False because neither 0.1 nor 0.2 is exact in binary.

Practice

Convert −37 to 8-bit two’s complement and explain why summing money in floating point is risky.

Continue in the learning spaceEnrol to open every lesson, track your progress, hand in work for faculty review and ask your tutor.Enrol — One-to-One