This repository was archived by the owner on Apr 28, 2025. It is now read-only.
File tree 3 files changed +37
-38
lines changed
3 files changed +37
-38
lines changed Original file line number Diff line number Diff line change 4
4
/math /src
5
5
/math /target
6
6
/target
7
- /tests
8
7
Cargo.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
+ use libm:: * ;
5
+
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
+ 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} ;
4
1
use libm:: * ;
5
2
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
-
40
3
#[ test]
41
4
fn remquo_q_overflow ( ) {
42
5
// 0xc000000000000001, 0x04c0000000000004
You can’t perform that action at this time.
0 commit comments