This repository was archived by the owner on Apr 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +36
-38
lines changed Expand file tree Collapse file tree 3 files changed +36
-38
lines changed Original file line number Diff line number Diff line change 44/math /src
55/math /target
66/target
7- /tests
87Cargo.lock
Original file line number Diff line number Diff line change 1+ #![ cfg( all( test, feature = "musl-reference-tests" ) ) ]
2+
3+ use core:: { f32, f64} ;
4+
5+ /// Approximate equality with 1 ULP of tolerance
6+ #[ inline]
7+ fn _eqf ( a : f32 , b : f32 ) -> Result < ( ) , u32 > {
8+ if a. is_nan ( ) && b. is_nan ( ) {
9+ Ok ( ( ) )
10+ } else {
11+ let err = ( a. to_bits ( ) as i32 ) . wrapping_sub ( b. to_bits ( ) as i32 ) . abs ( ) ;
12+
13+ if err <= 1 {
14+ Ok ( ( ) )
15+ } else {
16+ Err ( err as u32 )
17+ }
18+ }
19+ }
20+
21+ #[ inline]
22+ fn _eq ( a : f64 , b : f64 ) -> Result < ( ) , u64 > {
23+ if a. is_nan ( ) && b. is_nan ( ) {
24+ Ok ( ( ) )
25+ } else {
26+ let err = ( a. to_bits ( ) as i64 ) . wrapping_sub ( b. to_bits ( ) as i64 ) . abs ( ) ;
27+
28+ if err <= 1 {
29+ Ok ( ( ) )
30+ } else {
31+ Err ( err as u64 )
32+ }
33+ }
34+ }
35+
36+ include ! ( concat!( env!( "OUT_DIR" ) , "/musl-tests.rs" ) ) ;
Original file line number Diff line number Diff line change 1- #![ cfg( test) ]
2-
3- use core:: { f32, f64} ;
41use libm:: * ;
52
6- /// Approximate equality with 1 ULP of tolerance
7- #[ inline]
8- fn _eqf ( a : f32 , b : f32 ) -> Result < ( ) , u32 > {
9- if a. is_nan ( ) && b. is_nan ( ) {
10- Ok ( ( ) )
11- } else {
12- let err = ( a. to_bits ( ) as i32 ) . wrapping_sub ( b. to_bits ( ) as i32 ) . abs ( ) ;
13-
14- if err <= 1 {
15- Ok ( ( ) )
16- } else {
17- Err ( err as u32 )
18- }
19- }
20- }
21-
22- #[ inline]
23- fn _eq ( a : f64 , b : f64 ) -> Result < ( ) , u64 > {
24- if a. is_nan ( ) && b. is_nan ( ) {
25- Ok ( ( ) )
26- } else {
27- let err = ( a. to_bits ( ) as i64 ) . wrapping_sub ( b. to_bits ( ) as i64 ) . abs ( ) ;
28-
29- if err <= 1 {
30- Ok ( ( ) )
31- } else {
32- Err ( err as u64 )
33- }
34- }
35- }
36-
37- #[ cfg( all( test, feature = "musl-reference-tests" ) ) ]
38- include ! ( concat!( env!( "OUT_DIR" ) , "/musl-tests.rs" ) ) ;
39-
403#[ test]
414fn remquo_q_overflow ( ) {
425 // 0xc000000000000001, 0x04c0000000000004
You can’t perform that action at this time.
0 commit comments