Main Content

realmax

Largest positive floating-point number

Description

example

f = realmax returns the largest finite floating-point number in IEEE® double precision. This is equal to (2-2^(-52))*2^1023.

example

f = realmax(precision) returns the largest finite floating-point number in IEEE single or double precision. This is equal to realmax for double precision, and to single((2-2^(-23))*2^127) for single precision.

example

f = realmax("like",p) returns the largest finite floating-point number with the same data type, sparsity, and complexity (real or complex) as the floating-point variable p.

Examples

collapse all

Set the output format to long scientific notation. Return the largest finite floating-point number in IEEE® double precision.

format long e
f = realmax
f = 
    1.797693134862316e+308

Return the largest finite floating-point number in IEEE® single precision.

f = realmax("single")
f = single
    3.4028e+38

Check the class of f.

class(f)
ans = 
'single'

Return the largest finite floating-point number with the same data type and complexity as an existing array.

First, create a complex vector of single data type.

p = single([0.12+2i -0.5i 3]);

Return the largest finite floating-point number as a scalar that is complex like p.

f = realmax("like",p)
f = single
    3.4028e+38 +0.0000e+00i

Create a 10-by-10 sparse matrix.

p = sparse(10,10,pi);

Return the largest finite floating-point number with the same data type and sparsity as p. The output is a 1-by-1 sparse matrix.

f = realmax("like",p)
f = 
   (1,1)     1.7977e+308

Input Arguments

collapse all

Floating-point precision type, specified as "double" or "single".

Prototype, specified as a floating-point variable.

Data Types: double | single
Complex Number Support: Yes

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced before R2006a