1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

math: update documentation (#14457)

This commit is contained in:
David 'Epper' Marshall
2022-05-20 01:45:54 -04:00
committed by GitHub
parent 23568f19da
commit 120f31b4d9
12 changed files with 108 additions and 51 deletions

View File

@ -155,6 +155,7 @@ pub fn signbit(x f64) bool {
return f64_bits(x) & sign_mask != 0
}
// tolerance checks if a and b difference are less than or equal to the tolerance value
pub fn tolerance(a f64, b f64, tol f64) bool {
mut ee := tol
// Multiplying by ee here can underflow denormal values to zero.
@ -178,14 +179,17 @@ pub fn tolerance(a f64, b f64, tol f64) bool {
return d < ee
}
// close checks if a and b are within 1e-14 of each other
pub fn close(a f64, b f64) bool {
return tolerance(a, b, 1e-14)
}
// veryclose checks if a and b are within 4e-16 of each other
pub fn veryclose(a f64, b f64) bool {
return tolerance(a, b, 4e-16)
}
// alike checks if a and b are equal
pub fn alike(a f64, b f64) bool {
if is_nan(a) && is_nan(b) {
return true