True or False: Boolean Is a Data Type?

Welcome back to the Digilent Blog!

True! Boolean is a data type. However, it’s also a term that gets thrown around in the electronics world by programmers presuming that everybody else knows what they are talking about; I can personally attest that this is not always the case. In light of this, let’s go over some of the data types that are commonly used in programming.

But first things first, what is a data type? In a broad sense, data types are ways to represent different kinds of information in a computer processor or FPGA. Today we will be discussing booleans, integers, chars, and floating point numbers, all of which are commonly known as primitive data types. There are also other types of data, known as composite data types, although these are generally just combinations of the primitive data types, such as an array. Computer processors, microprocessors, and FPGAs all store these data types in a binary format as a series of 1’s and 0’s. Within the computer system each ‘1’ or ‘0’ (a bit) is classically grouped together in sets of eight to form what is known as a byte. Because a processor will communicate in this byte format, every data type, even if it only needs one bit to be represented, will be stored inside of a byte.

32 bits of data will be sectioned off into four bytes with eight bits each.
32 bits of data will be sectioned off into four bytes with eight bits each.

A boolean, as you might have guessed, is a data type that represents “true” or “false”. However, when storing information on a computer, there is no hardware that is capable of storing a literal “true or false”, so many programming languages will instead have the true and false values be equivalent to the numbers ‘1’ and ‘0’ represented by high and low voltages. This allows for the potential operation of “true + true” being equal to ‘2’. How this fun fact is actually useful in a real life situation is beyond me, but hey, fun facts are still fun! The true or false nature of a boolean makes it a great way to keep track of something that is triggered “on or off” or “left and right”.

The two options for a Boolean data type. Image from

A character, commonly called a char, is an array of bits (one byte worth in C++) that define a visual representation of a symbol. These symbols are commonly defined by the ASCII table and consist of many of the characters that you see on your keyboard. Characters are technically a composite data type as many characters can be placed together to form a string (a series of characters) as well as the fact that an array of bits (representing pixels that can be turned on or off) are needed to display each of the characters. With the right resources, you can also define your own set of characters to display “non-standard” characters.


The PmodOLED displaying our two defined characters.
The PmodOLED displaying a variety of characters.

Integers, usually shortened to just int, are the standard way to store numbers within your code. They are able to store a variety of numbers including binary, decimal, and hexadecimal numbers and do not require any special manipulation process on the programmer’s part to store one number type over a different one inside of an int. On chipKIT™ boards with their PIC32 processor, integers are 32 bits long allowing them to store numbers ranging from -2,147,483,647 to +2,147,483,647 for the signed (positive or negative) and from 0 to 4,294,967,295 for the unsigned (just positive) version. Despite being natively 32 bits long, it is possible to declare an integer that is of a smaller value such as only 16 bits or 8 bits in order to conserve space within the processor, although naturally this will be done at the expense of an exponentially shortened number size that those integers can accept. The restriction with integers is that they are unable to accept any decimal places. If you attempted to give an integer a value of 31.96, it will only store the 31. The 0.96 will instead be truncated, meaning that it will be discarded entirely with no rounding whatsoever.


The inherent nature of an integer
The inherent nature of an integer.


The final data type that I will talk about is a floating point. This is a data type that is able to accept numbers with decimal places. The way that this data type works is through a style of scientific notation; a given number is arranged so that there is one value before the decimal point and the rest of the significant numbers are after the decimal point with eight bits out of the 32 dedicated towards the exponent indicating the magnitude of the number.


A breakdown of a 32-bit float. Image by Fresheneesz from this Wikipedia page.

In terms of real life application, this equates to a “float” being able to handle and keep track of about seven decimal points. A “double” is similar to a float, except that it uses two sets of 32 bits for a total of 64 bits (eight bytes). As a double-precision floating value (hence the name), it is able to keep track of about 16 decimal places, allowing for more accurate calculations, although calculations involving doubles do take longer than floats because they take up two slots of memory in a PIC32. Luckily, when running at 80 MHz on Digilent’s chipKIT boards, this time difference is negligible for most applications.


About James Colvin

The biggest thing that I enjoy is learning new things. Especially things involving some type of technology; computer components, fun gadgets, games, coding techniques, etc. I love spending time with my wife and our two sons and hanging out with our friends. During my normal work day, I manage the Digilent Forum and the North American Support team.

View all posts by James Colvin →

Leave a Reply

Your email address will not be published. Required fields are marked *