flintmax

Largest consecutive integer that floating point can hold exactly.

Category: Language Fundamentals > Data Types

Syntax

m = flintmax

Returns 2^53 for double.

m = flintmax('single')

Returns 2^24 for single.

Description

Up to flintmax, every integer is representable. Above it, the spacing between floating-point numbers exceeds 1, so some integers cannot be stored and flintmax + 1 rounds back to flintmax.

Input arguments

class
'double' (default) or 'single'.

Output arguments

m
Scalar of the requested class.

Example

Limit of exact integers

format long
flintmax
flintmax + 1 == flintmax
flintmax('single')
Output
ans = 9.007199254740992e+15
ans = logical
   1
ans = single
   16777216

See also

eps realmax intmax double single