Deep C Dives: All You Need Are Bits
Written by Mike James   
Wednesday, 21 January 2026
Article Index
Deep C Dives: All You Need Are Bits
Specifying Bit Patterns
Zero


You may not need a symbol for five but you do need a new symbol. You need to be able to mark an empty position i.e. to mark that there are no groups of one, five or 25. You could just use a space but we adopted the standard zero 0 to indicate that there are no groups of the specified size. So:

is one lot of 25, no lots of five and three ones, i.e. 28.

This is how the Romans might have invented the place value system if only they hadn’t kept on inventing symbols for ever bigger groups. The only cost is having to maintain the positions of the symbols and invent a zero. The payback is that arithmetic is much easier as you can work with each position in turn. For example, to add the number of cars seen yesterday (27) to those seen today (23):

   1     0    11 +
0 1111 111
= 1 1111 11111
= 1 11111 0
= 11 0 0

or 50 in our notation. Notice that the addition was performed one “column” at a time and then counts that are too big are moved to the next column, the “carry”.

This idea generalizes and if we work with groups of N and use the place value idea the first position counts from 0 to N-1, the second from N to Nx(N-⁠1), the next to NxNx(N-1) and so on. We never need to use the symbol for N, but we do need a symbol for zero.

Our standard system is base ten, for which we have ten digits, the symbols 0,1,2,3,4,5,6,7,8 and 9. In this base each place counts from 0 to 9 i.e. one less than 10 and there is no “digit” for 10. If you use all of the places then using just the first you can count from 0 to 9, using the first and the second gets you to 99 and using the third as well gets you to 999 and so on.

A less familiar system, hexadecimal or base 16, works in exactly the same way. In this case there are 16 symbols 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F and again there is no symbol for 16. The first place counts from 0 to F i.e. 15, the second counts lots of 16 from 00 to F0 i.e. 0 to 240 and FF is 255.

So now we understand how symbols can encode numbers. Next we need to look at how this works out using just 0 and 1

In book but not in this extract

  • Binary
  • Binary Arithmetic
  • Rollover
  • Negative Numbers

Deep C Dives
Adventures in C

By Mike James

Cdive360

Buy from Amazon.

Contents

Preface
Prolog C
Dive

  1. All You Need Are Bits
    Extract
    All You Need Are Bits ***NEW!
  2. These aren’t the types you’re looking for
  3. Type Casting
  4. Expressions
  5. Bits and More Bits
        Extract:
    Bits!
  6. The Brilliant But Evil for 
  7. Into the Void 
  8. Blocks, Stacks and Locals
  9. Static Storage
  10. Pointers
  11. The Array and Pointer Arithmetic
  12. Heap, The Third Memory Allocation
  13. First Class Functions
        Extract:
    First Class Functions
  14. Structs and Objects
        ExtractValue Structs 
  15. The Union
  16. Undefined Behavior
  17. Exceptions and the Long Jump

<ASIN:B0D6LZZQ8R>

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Facebook or Linkedin.

Banner


Rue: Steve Klabnik In Collaboration with Claude
14/01/2026

Steve Klabnik, longtime contributor to the Rust language, is working on his own language, called Rue. This is a hobby project being done for fun and to speed up development Steve's co-worker is Claude [ ... ]



Udacity Offers 40% Off
29/12/2025

Udacity is encouraging us to put the holiday time to good use with a special offer running until the New Year - 40% off across all its programs when you pay in advance. 


More News

pico book

 

Comments




or email your comment to: comments@i-programmer.info

 



Last Updated ( Wednesday, 21 January 2026 )