VOOZH about

URL: https://www.geeksforgeeks.org/matlab/matlab-floating-point-precision/

⇱ Matlab Floating Point Precision - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Matlab Floating Point Precision

Last Updated : 28 Apr, 2025

Numeric class in MATLAB includes signed and unsigned integers, single-precision floating-point numbers, and double-precision floating-point numbers. Generally, MATLAB stores all numeric values as double-precision floating-point.Floating Point Numbers in MATLAB are stored in two forms:

  1. Single Precision Floating point
  2. Double Precision Floating point

MATLAB keeps the double precision floating point as the default floating point representation however, it can be changed to single by a very simple function.

Single Precision Floating Point:

The single precision floating point number requires 32 bits for representation by the standards of IEE®. These 32 bits are formatted as following.

Bit Number/RangeBits' Functionality
31

Sign: -

0 for positive.

1 for negative.

30-23exponent part; biased by 127
22-0mantissa of the number; 1.f

Where exponent and mantissa are the components of exponential/scientific notation of a number.

Double Precision Floating Point:

The double precision floating point number requires 64 bits for representation by the standards of IEE®. These 64 bits are formatted as following.

Bit Number/RangeBits' Functionality
63

Sign: -

0 for positive.

1 for negative.

62-52exponent part; biased by 1023
51-0mantissa of the number; 1.f

Creating Single Floating Point and Double Floating Point in MATLAB:

Single Precision:

As MATLAB creates double precision floating point number by default, we use single() function to create single precision floating point number.

Example 1:

Output:

👁 Image
 

Double Precision:

Double precision floating point numbers can be created by ordinary assignment or using the double function.

Example 2:

Output:

👁 Image
 

As it can be seen, both num and num_assignment variables have same attributes of double type.

Comment