| 1 | #![cfg(feature = "f16")] |
| 2 | |
| 3 | use lexical_utilrust-analyzer cargo lexical-util 1.0.7 crate/::bf16rust-analyzer cargo lexical-util 1.0.7 bf16/::bf16rust-analyzer cargo float16 0.1.3 bfloat/bf16#; |
| 4 | use lexical_utilrust-analyzer cargo lexical-util 1.0.7 crate/::numrust-analyzer cargo lexical-util 1.0.7 num/::Floatrust-analyzer cargo lexical-util 1.0.7 num/Float#; |
| 5 | |
| 6 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 7 | fn as_f32_testrust-analyzer cargo lexical-util 1.0.7 as_f32_test().() { |
| 8 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bf16rust-analyzer cargo float16 0.1.3 bfloat/bf16#::from_bitsrust-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]from_bits().(1).as_f32rust-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]as_f32().(), 9.18355e-41f32); |
| 9 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bf16rust-analyzer cargo float16 0.1.3 bfloat/bf16#::ZEROrust-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]ZERO..as_f32_construst-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]as_f32_const().(), 0.0f32); |
| 10 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bf16rust-analyzer cargo float16 0.1.3 bfloat/bf16#::ZEROrust-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]ZERO..to_bitsrust-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]to_bits().(), 0); |
| 11 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bf16rust-analyzer cargo float16 0.1.3 bfloat/bf16#::ONErust-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]ONE..as_f32_construst-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]as_f32_const().(), 1.0f32); |
| 12 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bf16rust-analyzer cargo float16 0.1.3 bfloat/bf16#::ONErust-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]ONE..to_bitsrust-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]to_bits().(), (127 << 7)); |
| 13 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bf16rust-analyzer cargo float16 0.1.3 bfloat/bf16#::TWOrust-analyzer cargo lexical-util 1.0.7 num/impl#[bf16][Float]TWO..as_f32_construst-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]as_f32_const().(), 2.0f32); |
| 14 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bf16rust-analyzer cargo float16 0.1.3 bfloat/bf16#::TWOrust-analyzer cargo lexical-util 1.0.7 num/impl#[bf16][Float]TWO..to_bitsrust-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]to_bits().(), (128 << 7)); |
| 15 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bf16rust-analyzer cargo float16 0.1.3 bfloat/bf16#::from_bitsrust-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]from_bits().(126 << 7).as_f32_construst-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]as_f32_const().(), 0.5f32); |
| 16 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(bf16rust-analyzer cargo float16 0.1.3 bfloat/bf16#::NANrust-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]NAN..as_f32_construst-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]as_f32_const().().is_nanrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]is_nan().()); |
| 17 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(bf16rust-analyzer cargo float16 0.1.3 bfloat/bf16#::INFINITYrust-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]INFINITY..as_f32_construst-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]as_f32_const().().is_infrust-analyzer cargo lexical-util 1.0.7 num/Float#is_inf().()); |
| 18 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(bf16rust-analyzer cargo float16 0.1.3 bfloat/bf16#::NEG_INFINITYrust-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]NEG_INFINITY..as_f32_construst-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]as_f32_const().().is_infrust-analyzer cargo lexical-util 1.0.7 num/Float#is_inf().()); |
| 19 | } |
| 20 | |
| 21 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 22 | fn from_f32_testrust-analyzer cargo lexical-util 1.0.7 from_f32_test().() { |
| 23 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bf16rust-analyzer cargo float16 0.1.3 bfloat/bf16#::from_f32_construst-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]from_f32_const().(4.5917e-41f32).to_bitsrust-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]to_bits().(), 0); |
| 24 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bf16rust-analyzer cargo float16 0.1.3 bfloat/bf16#::from_f32_construst-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]from_f32_const().(4.5918e-41f32).to_bitsrust-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]to_bits().(), 0); |
| 25 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bf16rust-analyzer cargo float16 0.1.3 bfloat/bf16#::from_f32_construst-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]from_f32_const().(4.5919e-41f32).to_bitsrust-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]to_bits().(), 1); |
| 26 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bf16rust-analyzer cargo float16 0.1.3 bfloat/bf16#::from_f32_construst-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]from_f32_const().(9.18354e-41f32).to_bitsrust-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]to_bits().(), 1); |
| 27 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bf16rust-analyzer cargo float16 0.1.3 bfloat/bf16#::from_f32_construst-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]from_f32_const().(9.18355e-41f32).to_bitsrust-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]to_bits().(), 1); |
| 28 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bf16rust-analyzer cargo float16 0.1.3 bfloat/bf16#::from_f32_construst-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]from_f32_const().(9.18356e-41f32).to_bitsrust-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]to_bits().(), 1); |
| 29 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bf16rust-analyzer cargo float16 0.1.3 bfloat/bf16#::from_f32_construst-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]from_f32_const().(1.37752e-40f32).to_bitsrust-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]to_bits().(), 1); |
| 30 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bf16rust-analyzer cargo float16 0.1.3 bfloat/bf16#::from_f32_construst-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]from_f32_const().(1.37753e-40f32).to_bitsrust-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]to_bits().(), 2); |
| 31 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bf16rust-analyzer cargo float16 0.1.3 bfloat/bf16#::from_f32_construst-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]from_f32_const().(1.37754e-40f32).to_bitsrust-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]to_bits().(), 2); |
| 32 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(bf16rust-analyzer cargo float16 0.1.3 bfloat/bf16#::from_f32_construst-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]from_f32_const().(f32::NANrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]NAN.).is_nanrust-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]is_nan().()); |
| 33 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(bf16rust-analyzer cargo float16 0.1.3 bfloat/bf16#::from_f32_construst-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]from_f32_const().(f32::INFINITYrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]INFINITY.).is_infrust-analyzer cargo lexical-util 1.0.7 num/Float#is_inf().()); |
| 34 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(bf16rust-analyzer cargo float16 0.1.3 bfloat/bf16#::from_f32_construst-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]from_f32_const().(f32::NEG_INFINITYrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]NEG_INFINITY.).is_infrust-analyzer cargo lexical-util 1.0.7 num/Float#is_inf().()); |
| 35 | } |
| 36 | |
| 37 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 38 | fn math_testsrust-analyzer cargo lexical-util 1.0.7 math_tests().() { |
| 39 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bf16rust-analyzer cargo float16 0.1.3 bfloat/bf16#::ONErust-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]ONE. +rust-analyzer cargo float16 0.1.3 bfloat/impl#[bf16][`Add<Self>`]add(). bf16rust-analyzer cargo float16 0.1.3 bfloat/bf16#::ONErust-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]ONE., bf16rust-analyzer cargo float16 0.1.3 bfloat/bf16#::TWOrust-analyzer cargo lexical-util 1.0.7 num/impl#[bf16][Float]TWO.); |
| 40 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bf16rust-analyzer cargo float16 0.1.3 bfloat/bf16#::ONErust-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]ONE. *rust-analyzer cargo float16 0.1.3 bfloat/impl#[bf16][`Mul<Self>`]mul(). bf16rust-analyzer cargo float16 0.1.3 bfloat/bf16#::ONErust-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]ONE., bf16rust-analyzer cargo float16 0.1.3 bfloat/bf16#::ONErust-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]ONE.); |
| 41 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bf16rust-analyzer cargo float16 0.1.3 bfloat/bf16#::ONErust-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]ONE. /rust-analyzer cargo float16 0.1.3 bfloat/impl#[bf16][`Div<Self>`]div(). bf16rust-analyzer cargo float16 0.1.3 bfloat/bf16#::ONErust-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]ONE., bf16rust-analyzer cargo float16 0.1.3 bfloat/bf16#::ONErust-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]ONE.); |
| 42 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bf16rust-analyzer cargo float16 0.1.3 bfloat/bf16#::ONErust-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]ONE. -rust-analyzer cargo float16 0.1.3 bfloat/impl#[bf16][`Sub<Self>`]sub(). bf16rust-analyzer cargo float16 0.1.3 bfloat/bf16#::ONErust-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]ONE., bf16rust-analyzer cargo float16 0.1.3 bfloat/bf16#::ZEROrust-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]ZERO.); |
| 43 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bf16rust-analyzer cargo float16 0.1.3 bfloat/bf16#::ONErust-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]ONE. %rust-analyzer cargo float16 0.1.3 bfloat/impl#[bf16][`Rem<Self>`]rem(). bf16rust-analyzer cargo float16 0.1.3 bfloat/bf16#::ONErust-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]ONE., bf16rust-analyzer cargo float16 0.1.3 bfloat/bf16#::ZEROrust-analyzer cargo float16 0.1.3 bfloat/impl#[bf16]ZERO.); |
| 44 | } |