Floating Point Number Conversion

Converts floating point numbers between decimal and IEEE 754 binary representation
Updated 20 Nov 2012

View License

This package is designed to convert floating point point numbers from their decimal to their binary formats, according to the IEEE 754 standard. This is useful when calculations at the limits of MATLAB precision are performed or when the binary strings are of interest, such as in genetic algorithms. The package consists of the following four scripts.

float2bin: converts decimal floating point numbers to IEEE 754 binary string

bin2float: converts binary string to floating point number

bitstr2vec: converts binary string to binary vector of 0s and 1s

bitvec2str: converts binary vector to binary string

The floating point format that Matlab utilizes and some functions relating to floating point precision and limits are described in this post:


The float2bin function included in this package is described in this post:


Cite As

Eric Verner (2024). Floating Point Number Conversion (https://www.mathworks.com/matlabcentral/fileexchange/39113-floating-point-number-conversion), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R14
Compatible with any release
Platform Compatibility
Windows macOS Linux
Find more on Numeric Types in Help Center and MATLAB Answers

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes