image thumbnail

Binary Representation of Numbers in Matlab

version 1.0.0.0 (58.5 KB) by Munther
To learn how numbers are represented and stored in Matlab memory.

197 Downloads

Updated 01 Nov 2011

View License

When we represent numbers, we use digits 0 to 9 and a decimal point. When a computer represents numbers, it uses 0 and 1 digits, and we refer to this as binary representation of numbers.
As mentioned earlier, numbers can be classified into integer numbers and real numbers. Both types are represented by a computer differently. Even though, there are different representations for each type. For example, Matlab supports eight data types to represent integer numbers and two data types to represent real numbers. Matlab documentations refer to data types as classes. We will use both terms interchangeably in this lesson.
The data types Matlab supports to represent integer numbers are: uint8, uint16, uint32, uint64, int8, int16, int32 and int64. The data types Matlab supports to represent real numbers are: single and double.

The letter ‘u’ in the uint8, uint16, uint32, uint64 refers to unsigned data type. These classes can only store positive integer numbers.

Matlab allows you to change the values of bits for the classes uint8, uint16, uint32, uint64 only. Studying the binary representation of these classes is the most important part of this tutorial.
Matlab supports other data formats such as fractional, fixed point, and user defined float data types. These data types will not be discussed in this tutorial.

Cite As

Munther (2021). Binary Representation of Numbers in Matlab (https://www.mathworks.com/matlabcentral/fileexchange/33557-binary-representation-of-numbers-in-matlab), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2010b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!