Text of rust.docs.kernel.org β€Ί core β€Ί primitive.f128.html as Styx crawled it on Nov 19, 2026. The page may have changed since. Only its words are kept, without pictures or layout, and only the first part of a long page.

Open the live page

f128 - Rust

Skip to main content f128 Primitive Type f128 πŸ”¬ This is a nightly-only experimental API. ( f128 #116909 ) Expand description A 128-bit floating-point type (specifically, the β€œbinary128” type defined in IEEE 754-2008). This type is very similar to f32 and f64 , but has increased precision by using twice as many bits as f64 . Please see the documentation for f32 or Wikipedia on quad-precision values for more information.

Note that no platforms have hardware support for f128 without enabling target specific features, as for all instruction set architectures f128 is considered an optional feature. Only Power ISA (β€œPowerPC”) and RISC-V (via the Q extension) specify it, and only certain microarchitectures actually implement it. For x86-64 and AArch64, ISA support is not even specified, so it will always be a software implementation significantly slower than f64 .

Note: f128 support is incomplete. Many platforms will not be able to link math functions. On x86 in particular, these functions do link but their results are always incorrect. See also the std::f128::consts module . Implementations Β§ Source Β§ impl f128 Source pub const RADIX : u32 = 2 πŸ”¬ This is a nightly-only experimental API. ( f128 #116909 ) The radix or base of the internal representation of f128 . Source pub const BITS : u32 = 128 πŸ”¬ This is a nightly-only experimental API. ( float_bits_const #151073 ) The size of this float type in bits.

Source pub const MANTISSA_DIGITS : u32 = 113 πŸ”¬ This is a nightly-only experimental API. ( f128 #116909 ) Number of significant digits in base 2. Note that the size of the mantissa in the bitwise representation is one smaller than this since the leading 1 is not stored explicitly. Source pub const DIGITS : u32 = 33 πŸ”¬ This is a nightly-only experimental API. ( f128 #116909 ) Approximate number of significant digits in base 10.

This is the maximum x such that any decimal number with x significant digits can be converted to f128 and back without loss. Equal to floor(log 10 2 MANTISSA_DIGITS βˆ’ 1 ). Source pub const EPSILON : f128 = 1.92592994438723585305597794258492732e-34_f128 πŸ”¬ This is a nightly-only experimental API. ( f128 #116909 ) Machine epsilon value for f128 . This is the difference between 1.0 and the next larger representable number.

Equal to 2 1 βˆ’ MANTISSA_DIGITS . Source pub const MIN : f128 = -1.18973149535723176508575932662800702e+4932_f128 πŸ”¬ This is a nightly-only experimental API. ( f128 #116909 ) Smallest finite f128 value. Equal to βˆ’ MAX . Source pub const MIN_POSITIVE : f128 = 3.36210314311209350626267781732175260e-4932_f128 πŸ”¬ This is a nightly-only experimental API. ( f128 #116909 ) Smallest positive normal f128 value. Equal to 2 MIN_EXP βˆ’ 1 .

Source pub const MAX : f128 = 1.18973149535723176508575932662800702e+4932_f128 πŸ”¬ This is a nightly-only experimental API. ( f128 #116909 ) Largest finite f128 value. Equal to (1 βˆ’ 2 βˆ’ MANTISSA_DIGITS ) 2 MAX_EXP . Source pub const MIN_EXP : i32 = -16_381 πŸ”¬ This is a nightly-only experimental API. ( f128 #116909 ) One greater than the minimum possible normal power of 2 exponent for a significand bounded by 1 ≀ x < 2 (i.e. the IEEE definition).

This corresponds to the exact minimum possible normal power of 2 exponent for a significand bounded by 0.5 ≀ x < 1 (i.e. the C definition). In other words, all normal numbers representable by this type are greater than or equal to 0.5 Γ— 2 MIN_EXP . Source pub const MAX_EXP : i32 = 16_384 πŸ”¬ This is a nightly-only experimental API. ( f128 #116909 ) One greater than the maximum possible power of 2 exponent for a significand bounded by 1 ≀ x < 2 (i.e. the IEEE definition).

This corresponds to the exact maximum possible power of 2 exponent for a significand bounded by 0.5 ≀ x < 1 (i.e. the C definition). In other words, all numbers representable by this type are strictly less than 2 MAX_EXP . Source pub const MIN_10_EXP : i32 = -4_931 πŸ”¬ This is a nightly-only experimental API. ( f128 #116909 ) Minimum x for which 10 x is normal. Equal to ceil(log 10 MIN_POSITIVE ). Source pub const MAX_10_EXP : i32 = 4_932 πŸ”¬ This is a nightly-only experimental API. ( f128 #116909 ) Maximum x for which 10 x is normal.

Equal to floor(log 10 MAX ). Source pub const NAN : f128 πŸ”¬ This is a nightly-only experimental API. ( f128 #116909 ) Not a Number (NaN). Note that IEEE 754 doesn’t define just a single NaN value; a plethora of bit patterns are considered to be NaN. Furthermore, the standard makes a difference between a β€œsignaling” and a β€œquiet” NaN, and allows inspecting its β€œpayload” (the unspecified bits in the bit pattern) and its sign.

See the specification of NaN bit patterns for more info. This constant is guaranteed to be a quiet NaN (on targets that follow the Rust assumptions that the quiet/signaling bit being set to 1 indicates a quiet NaN). Beyond that, nothing is guaranteed about the specific bit pattern chosen here: both payload and sign are arbitrary. The concrete bit pattern may change across Rust versions and target platforms. Source pub const INFINITY : f128 πŸ”¬ This is a nightly-only experimental API. ( f128 #116909 ) Infinity (∞).

Source pub const NEG_INFINITY : f128 πŸ”¬ This is a nightly-only experimental API. ( f128 #116909 ) Negative infinity (βˆ’βˆž). Source pub const MAX_EXACT_INTEGER : i128 πŸ”¬ This is a nightly-only experimental API. ( float_exact_integer_constants #152466 ) Maximum integer that can be represented exactly in an f128 value, with no other integer converting to the same floating point value. For an integer x which satisfies MIN_EXACT_INTEGER <= x <= MAX_EXACT_INTEGER , there is a β€œone-to-one” mapping between i128 and f128 values.

MAX_EXACT_INTEGER + 1 also converts losslessly to f128 and back to i128 , but MAX_EXACT_INTEGER + 2 converts to the same f128 value (and back to MAX_EXACT_INTEGER + 1 as an integer) so there is not a β€œone-to-one” mapping. #![feature(f128)] #![feature(float_exact_integer_constants)] let max_exact_int = f128::MAX_EXACT_INTEGER; assert_eq! (max_exact_int, max_exact_int as f128 as i128); assert_eq! (max_exact_int + 1 , (max_exact_int + 1 ) as f128 as i128); assert_ne! (max_exact_int + 2 , (max_exact_int + 2 ) as f128 as i128); // Beyond `f128::MAX_EXACT_INTEGER`, multiple integers can map to one float value assert_eq! ((max_exact_int + 1 ) as f128, (max_exact_int + 2 ) as f128); Source pub const MIN_EXACT_INTEGER : i128 πŸ”¬ This is a nightly-only experimental API. ( float_exact_integer_constants #152466 ) Minimum integer that can be represented exactly in an f128 value, with no other integer converting to the same floating point value.

For an integer x which satisfies MIN_EXACT_INTEGER <= x <= MAX_EXACT_INTEGER , there is a β€œone-to-one” mapping between i128 and f128 values. MAX_EXACT_INTEGER + 1 also converts losslessly to f128 and back to i128 , but MAX_EXACT_INTEGER + 2 converts to the same f128 value (and back to MAX_EXACT_INTEGER + 1 as an integer) so there is not a β€œone-to-one” mapping. This constant is equivalent to -MAX_EXACT_INTEGER . #![feature(f128)] #![feature(float_exact_integer_constants)] let min_exact_int = f128::MIN_EXACT_INTEGER; assert_eq! (min_exact_int, min_exact_int as f128 as i128); assert_eq! (min_exact_int - 1 , (min_exact_int - 1 ) as f128 as i128); assert_ne! (min_exact_int - 2 , (min_exact_int - 2 ) as f128 as i128); // Below `f128::MIN_EXACT_INTEGER`, multiple integers can map to one float value assert_eq! ((min_exact_int - 1 ) as f128, (min_exact_int - 2 ) as f128); Source pub const SIGN_MASK : u128 = 0x8000_0000_0000_0000_0000_0000_0000_0000 πŸ”¬ This is a nightly-only experimental API. ( float_masks #154064 ) The mask of the bit used to encode the sign of an f128 .

This bit is set when the sign is negative and unset when the sign is positive. If you only need to check whether a value is positive or negative, is_sign_positive or is_sign_negative can be used. #![feature(float_masks)] #![feature

The rest of this page is on the live site.