# The Binary Book

### By Steven Roman

The Binary Book is an electronic book that is roughly equivalent in size to a 100-page printed book. I am distributing it as a compiled HTML (CHM) help file, complete with a table of contents (see below), index and full-text search capability.

The Binary Book sells for \$12.95. To purchase by credit card through PayPal, click the PayPal image below. I will email the book to you (the file is about 600KB) as soon as I am able, which is generally within 24 hours of purchase.

## Introduction to the Book

Being a good programmer requires both skill and knowledge. Certainly, a programmer needs to have a solid understanding of his (or her) preferred programming languages, as well as the subject matter of the applications under development. But this is not enough. There is more to being an effective programmer.

This book delves into three areas of importance to programmers, areas that are all too often neglected.

• A look at binary, octal and hexadecimal number formats and their use by the computer. This includes converting between binary, octal, decimal and hexadecimal bases.
• A look at how to manipulate the individual bits in a binary string, that is, a bit flag.
• A look at data types, with examples drawn from both Visual Basic and Visual C++. This includes a look at signed and unsigned numerical data types, floating data types, strings, pointers and structures.
• A look at the basic principles of elementary logic. In particular, a look at the meaning of the various logical operators (AND, OR, NOT, XOR and so on).

## Sample Chapter

```The Binary Book
Introduction

Part I - Bit Manipulation
Chapter 1 - Binary Strings
Binary Strings
Why Binary
Lots of Bytes
A Byte of Confusion
Interpreting Binary Strings
Binary Strings As Characters-Character Codes
ASCII
ANSI
DBCS
Unicode
Unicode Support Under Windows
Binary Strings as Instructions
A Quick Peek at Memory
Big Endian and Little Endian
Chapter 2 - Binary and Hexadecimal Number Formats
Decimal Format
Binary Format
Some Useful Functions
Visual Basic
Visual C++
What's Wrong with the Binary Format
Octal Format
Converting Between Octal and Binary
Chapter 3 - Bitwise Manipulations
Flags
A Visual Basic Example
A Visual C++ Example
Bitwise Operators
The Basic Bitwise Operators
Two More Bitwise Operators
Bitwise Manipulations
Examples
Example 1 - Clearing Bits in a Flag
Example 2 - Setting Bits in a Flag
Example 3 - Reversing Bits in a Flag
Example 4 - Retrieving the Value of a Bit in a Flag
Summary
Using Symbolic Constants with Bit Flags
A Visual Basic Example
A Visual C++ Example

Part II - Data Types
Chapter 4 - Preliminaries
Variables
Name
Type
Value
Variable Scope
Static Variables
Pointers
By Indirections Find Directions Out
Pointers in Visual Basic
CopyMemory - A VB Hackers Dream
A Simple Example
A More Interesting Example
Chapter 5 - Data Types
What is a Data Type
An Example-Integer Data Types
The VC++ Unsigned Integer Data Type
The VC++ Integer Data Type
The Visual Basic Integer Data Type
Groups of Data Types
Fundamental and Derived Data Types
Chapter 6 - Visual Basic Data Types
Variants
User-Defined Types
Chapter 7 - Basic VC++ Data Types
TypeDefs
Char Data Types
Unicode Character Types
Int Data Types
Floating Point Data Types
Other Data Types
Void
FARPROC
HANDLE
Boolean Data Types
Summary
Chapter 8 - Signed and Unsigned Integer Data Types
Signed and Unsigned Representations
Why Two Different Representations
Unsigned Representation
Signed Representation
The Signed-Magnitude Representation
The Two's Complement Representation
Why Is It Called Two's Complement
Translating Between Signed and Unsigned Representations
Integers
Longs
Bytes
Examples
Converting Between Word Lengths
Chapter 9 - Floating Point Data Types
Binary Expansions
IEEE Floating Point Numbers
Displaying Binary Expansions
Chapter 10 - Strings
The BSTR
VC++ Strings
VarPtr and StrPtr

Part III - Logic
Chapter 11 - Statements and Connectives
Statements and Connectives
Simple and Compound Statements
Logical Statements and Programming Statements
Truth Values
Symbolic Form
The Connectives
Negation
Conjunction
Disjunction
Exclusive Or
Nand and Nor
The Conditional
The Biconditional
Chapter 12 - Truth Tables