mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
19 lines
194 B
V
19 lines
194 B
V
|
module math
|
||
|
|
||
|
// Returns the absolute value.
|
||
|
[inline]
|
||
|
pub fn abs(x f64) f64 {
|
||
|
if x > 0.0 {
|
||
|
return x
|
||
|
}
|
||
|
return -x
|
||
|
}
|
||
|
|
||
|
[inline]
|
||
|
pub fn fabs(x f64) f64 {
|
||
|
if x > 0.0 {
|
||
|
return x
|
||
|
}
|
||
|
return -x
|
||
|
}
|