Skip to content

Commit

Permalink
Merge pull request #274 from ZagButNoZig/master
Browse files Browse the repository at this point in the history
  • Loading branch information
Amanieu committed Nov 18, 2022
2 parents 4c8a973 + 415b0d0 commit dc82800
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/math/sqrt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,4 +261,20 @@ mod tests {
assert_eq!(sqrt(f), f);
}
}

#[test]
fn conformance_tests() {
let values = [3.14159265359, 10000.0, f64::from_bits(0x0000000f), INFINITY];
let results = [
4610661241675116657u64,
4636737291354636288u64,
2197470602079456986u64,
9218868437227405312u64,
];

for i in 0..values.len() {
let bits = f64::to_bits(sqrt(values[i]));
assert_eq!(results[i], bits);
}
}
}
16 changes: 16 additions & 0 deletions src/math/sqrtf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,20 @@ mod tests {
assert_eq!(sqrtf(f), f);
}
}

#[test]
fn conformance_tests() {
let values = [
3.14159265359f32,
10000.0f32,
f32::from_bits(0x0000000f),
INFINITY,
];
let results = [1071833029u32, 1120403456u32, 456082799u32, 2139095040u32];

for i in 0..values.len() {
let bits = f32::to_bits(sqrtf(values[i]));
assert_eq!(results[i], bits);
}
}
}

0 comments on commit dc82800

Please sign in to comment.