Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
8923b58
Document restricted_std
adamgemmell Feb 28, 2024
8a24ddf
Be more specific when flagging imports that are redundant due to the …
fmease Mar 23, 2024
0ef49fe
Stabilize `cstr_count_bytes`
tgross35 Apr 9, 2024
796be88
Use `fn` ptr signature instead of `{closure@..}` in infer error
estebank Apr 10, 2024
c8490a0
skip `unused_parens`'s suggestion for `Paren` in macro.
surechen Apr 1, 2024
88bcc79
Revert "Put basic impls for f16 and f128 behind cfg(not(bootstrap))"
tgross35 Apr 5, 2024
454de78
Add basic library support for `f16` and `f128`
tgross35 Mar 6, 2024
143ecc3
Add basic f16 and f128 modules
tgross35 Mar 26, 2024
311ad55
Add primitive documentation for `f16` and `f128`
tgross35 Apr 6, 2024
f0fd5ad
clean up docs for `File::sync_*`
Apr 10, 2024
3764af6
Use suggest_impl_trait in return type suggestion
compiler-errors Apr 10, 2024
aac3f24
Rollup merge of #122470 - tgross35:f16-f128-step4-libs-min, r=Amanieu
fmease Apr 10, 2024
ccab2b1
Rollup merge of #122954 - fmease:defined-by-extern-prelude, r=petroch…
fmease Apr 10, 2024
82c6f18
Rollup merge of #123314 - surechen:fix_120642, r=Nadrieril
fmease Apr 10, 2024
084d27b
Rollup merge of #123360 - adamgemmell:dev/adagem01/restricted-std, r=…
fmease Apr 10, 2024
d7d5be0
Rollup merge of #123661 - tgross35:stabilize-cstr_count_bytes, r=dtolnay
fmease Apr 10, 2024
ae88766
Rollup merge of #123703 - estebank:diag-changes-2, r=Nadrieril
fmease Apr 10, 2024
b24d2ad
Rollup merge of #123756 - lukas-code:file-sync, r=jhpratt
fmease Apr 10, 2024
2930dce
Rollup merge of #123761 - compiler-errors:suggest-more-impl-trait, r=…
fmease Apr 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add basic f16 and f128 modules
Create empty modules so `rustdoc` has someplace to link to for these
types.
  • Loading branch information
tgross35 committed Apr 10, 2024
commit 143ecc3202e033cf843bc05c06d29cd3e4033497
4 changes: 4 additions & 0 deletions library/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,10 @@ pub mod u8;
#[path = "num/shells/usize.rs"]
pub mod usize;

#[path = "num/f128.rs"]
pub mod f128;
#[path = "num/f16.rs"]
pub mod f16;
#[path = "num/f32.rs"]
pub mod f32;
#[path = "num/f64.rs"]
Expand Down
16 changes: 16 additions & 0 deletions library/core/src/num/f128.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//! Constants for the `f128` quadruple-precision floating point type.
//!
//! *[See also the `f128` primitive type][f128].*
//!
//! Mathematically significant numbers are provided in the `consts` sub-module.
//!
//! For the constants defined directly in this module
//! (as distinct from those defined in the `consts` sub-module),
//! new code should instead use the associated constants
//! defined directly on the `f128` type.

#![unstable(feature = "f128", issue = "116909")]

/// Basic mathematical constants.
#[unstable(feature = "f128", issue = "116909")]
pub mod consts {}
16 changes: 16 additions & 0 deletions library/core/src/num/f16.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//! Constants for the `f16` half-precision floating point type.
//!
//! *[See also the `f16` primitive type][f16].*
//!
//! Mathematically significant numbers are provided in the `consts` sub-module.
//!
//! For the constants defined directly in this module
//! (as distinct from those defined in the `consts` sub-module),
//! new code should instead use the associated constants
//! defined directly on the `f16` type.

#![unstable(feature = "f16", issue = "116909")]

/// Basic mathematical constants.
#[unstable(feature = "f16", issue = "116909")]
pub mod consts {}
11 changes: 11 additions & 0 deletions library/std/src/f128.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//! Constants for the `f128` double-precision floating point type.
//!
//! *[See also the `f128` primitive type](primitive@f128).*
//!
//! Mathematically significant numbers are provided in the `consts` sub-module.

#[cfg(test)]
mod tests;

#[unstable(feature = "f128", issue = "116909")]
pub use core::f128::consts;
40 changes: 40 additions & 0 deletions library/std/src/f128/tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#![allow(dead_code)] // FIXME(f16_f128): remove once constants are used

/// Smallest number
const TINY_BITS: u128 = 0x1;
/// Next smallest number
const TINY_UP_BITS: u128 = 0x2;
/// Exponent = 0b11...10, Sifnificand 0b1111..10. Min val > 0
const MAX_DOWN_BITS: u128 = 0x7ffeffffffffffffffffffffffffffff;
/// Zeroed exponent, full significant
const LARGEST_SUBNORMAL_BITS: u128 = 0x0000ffffffffffffffffffffffffffff;
/// Exponent = 0b1, zeroed significand
const SMALLEST_NORMAL_BITS: u128 = 0x00010000000000000000000000000000;
/// First pattern over the mantissa
const NAN_MASK1: u128 = 0x0000aaaaaaaaaaaaaaaaaaaaaaaaaaaa;
/// Second pattern over the mantissa
const NAN_MASK2: u128 = 0x00005555555555555555555555555555;

/// Compare by value
#[allow(unused_macros)]
macro_rules! assert_f128_eq {
($a:expr, $b:expr) => {
let (l, r): (&f128, &f128) = (&$a, &$b);
assert_eq!(*l, *r, "\na: {:#0130x}\nb: {:#0130x}", l.to_bits(), r.to_bits())
};
}

/// Compare by representation
#[allow(unused_macros)]
macro_rules! assert_f128_biteq {
($a:expr, $b:expr) => {
let (l, r): (&f128, &f128) = (&$a, &$b);
let lb = l.to_bits();
let rb = r.to_bits();
assert_eq!(
lb, rb,
"float {:?} is not bitequal to {:?}.\na: {:#0130x}\nb: {:#0130x}",
*l, *r, lb, rb
);
};
}
11 changes: 11 additions & 0 deletions library/std/src/f16.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//! Constants for the `f16` double-precision floating point type.
//!
//! *[See also the `f16` primitive type](primitive@f16).*
//!
//! Mathematically significant numbers are provided in the `consts` sub-module.

#[cfg(test)]
mod tests;

#[unstable(feature = "f16", issue = "116909")]
pub use core::f16::consts;
46 changes: 46 additions & 0 deletions library/std/src/f16/tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#![allow(dead_code)] // FIXME(f16_f128): remove once constants are used

// We run out of precision pretty quickly with f16
const F16_APPROX_L1: f16 = 0.001;
const F16_APPROX_L2: f16 = 0.01;
const F16_APPROX_L3: f16 = 0.1;
const F16_APPROX_L4: f16 = 0.5;

/// Smallest number
const TINY_BITS: u16 = 0x1;
/// Next smallest number
const TINY_UP_BITS: u16 = 0x2;
/// Exponent = 0b11...10, Sifnificand 0b1111..10. Min val > 0
const MAX_DOWN_BITS: u16 = 0x7bfe;
/// Zeroed exponent, full significant
const LARGEST_SUBNORMAL_BITS: u16 = 0x03ff;
/// Exponent = 0b1, zeroed significand
const SMALLEST_NORMAL_BITS: u16 = 0x0400;
/// First pattern over the mantissa
const NAN_MASK1: u16 = 0x02aa;
/// Second pattern over the mantissa
const NAN_MASK2: u16 = 0x0155;

/// Compare by value
#[allow(unused_macros)]
macro_rules! assert_f16_eq {
($a:expr, $b:expr) => {
let (l, r): (&f16, &f16) = (&$a, &$b);
assert_eq!(*l, *r, "\na: {:#018x}\nb: {:#018x}", l.to_bits(), r.to_bits())
};
}

/// Compare by representation
#[allow(unused_macros)]
macro_rules! assert_f16_biteq {
($a:expr, $b:expr) => {
let (l, r): (&f16, &f16) = (&$a, &$b);
let lb = l.to_bits();
let rb = r.to_bits();
assert_eq!(
lb, rb,
"float {:?} is not bitequal to {:?}.\na: {:#018x}\nb: {:#018x}",
*l, *r, lb, rb
);
};
}
6 changes: 6 additions & 0 deletions library/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@
#![feature(doc_masked)]
#![feature(doc_notable_trait)]
#![feature(dropck_eyepatch)]
#![feature(f128)]
#![feature(f16)]
#![feature(if_let_guard)]
#![feature(intra_doc_pointers)]
#![feature(lang_items)]
Expand Down Expand Up @@ -558,6 +560,10 @@ pub use core::u8;
#[allow(deprecated, deprecated_in_future)]
pub use core::usize;

#[unstable(feature = "f128", issue = "116909")]
pub mod f128;
#[unstable(feature = "f16", issue = "116909")]
pub mod f16;
pub mod f32;
pub mod f64;

Expand Down