float

Create a MATLAB structure describing a floating-point data type.

Syntax

a = float('single')

a = float('double')

a = float(TotalBits, ExpBits)

Description

float('single') returns a MATLAB structure that describes the data type of an IEEE single (32 total bits, 8 exponent bits). 

float('double') returns a MATLAB structure that describes the data type of an IEEE double (64 total bits, 11 exponent bits). 

float(TotalBits, ExpBits) returns a MATLAB structure that describes a nonstandard floating-point data type that mimics the IEEE style. That is, the numbers are normalized with a hidden leading one for all exponents except the smallest possible exponent. However, the largest possible exponent might not be treated as a flag for Inf's and NaN's.

float is automatically called when a floating point number is specified in a block dialog box.

Unlike fixed-point numbers, floating point numbers are not subject to any specified scaling.

Example

Define a nonstandard, IEEE-style, floating-point data type with 31 total bits (excluding the hidden leading one) and 9 exponent bits.

a = float(31,9)

a =

Class: 'FLOAT'

MantBits: 21

ExpBits: 9