Crates.io | f256 |
lib.rs | f256 |
version | 0.5.0 |
source | src |
created_at | 2023-03-01 07:30:34.829358 |
updated_at | 2024-10-09 12:15:44.756878 |
description | Octuple-precision floating-point arithmetic. |
homepage | https://github.com/mamrhein/f256.rs |
repository | https://github.com/mamrhein/f256.rs |
max_upload_size | |
id | 797814 |
size | 1,000,427 |
This crate provides an implementation of octuple-precision binary floating-point arithmetics.
"In its 2008 revision, the IEEE 754 standard specifies a binary256
format
among the interchange formats (it is not a basic format), as having:
Sign bit: 1 bit
Exponent width: 19 bits
Significand precision: 237 bits (236 explicitly stored)
The format is written with an implicit lead bit with value 1 unless the exponent is all zeros. Thus only 236 bits of the significand appear in the memory format, but the total precision is 237 bits (approximately 71 decimal digits: log₁₀(2²³⁷) ≈ 71.344). The bits are laid out as follows:
The octuple-precision binary floating-point exponent is encoded using an offset binary representation, with the zero offset being 262143; also known as exponent bias in the IEEE 754 standard.
Eₘᵢₙ = −262142
Eₘₐₓ = 262143
Exponent bias = 3FFFF₁₆ = 262143
Thus, as defined by the offset binary representation, in order to get the true exponent the offset of 262143 has to be subtracted from the stored exponent.
The stored exponents 00000₁₆ and 7FFFF₁₆ are interpreted specially.
Exponent | Significand zero | Significand non-zero | Equation |
---|---|---|---|
00000₁₆ | 0, −0 | subnormal numbers | (-1)signbit × 2⁻²⁶²¹⁴² × 0.significandbits₂ |
00001₁₆ … 7FFFE₁₆ | normalized value | normalized value | (-1)signbit × 2exponent bits₂ × 1.significandbits₂ |
7FFFF₁₆ | ±∞ | NaN (quiet, signalling) |
The minimum strictly positive (subnormal) value is 2⁻²⁶²³⁷⁸ ≈ 10⁻⁷⁸⁹⁸⁴ and has a precision of only one bit. The minimum positive normal value is 2⁻²⁶²¹⁴² ≈ 2.4824 × 10⁻⁷⁸⁹¹³. The maximum representable value is 2²⁶²¹⁴⁴ − 2²⁶¹⁹⁰⁷ ≈ 1.6113 × 10⁷⁸⁹¹³.
The type f256
will provide the same stable API as the built-in f64
(besides differences caused by the increased precision).
Add f256
to your Cargo.toml
:
[dependencies]
f256 = "0.3"
By default, only the feature std
is enabled.
alloc
so
that this functionality is also available in non-standard environments.num-traits::Num
is implemented
for f256
.