parent
8b085a32a5
commit
2d9fa62941
|
@ -408,6 +408,16 @@ fn test_abs() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn test_abs_zero() {
|
||||||
|
ret1 := abs(0)
|
||||||
|
println(ret1)
|
||||||
|
assert '$ret1' == '0'
|
||||||
|
|
||||||
|
ret2 := abs(0.0)
|
||||||
|
println(ret2)
|
||||||
|
assert '$ret2' == '0'
|
||||||
|
}
|
||||||
|
|
||||||
fn test_floor() {
|
fn test_floor() {
|
||||||
for i := 0; i < math.vf_.len; i++ {
|
for i := 0; i < math.vf_.len; i++ {
|
||||||
f := floor(math.vf_[i])
|
f := floor(math.vf_[i])
|
||||||
|
|
|
@ -18,5 +18,5 @@ pub fn max<T>(a T, b T) T {
|
||||||
// abs returns the absolute value of `a`
|
// abs returns the absolute value of `a`
|
||||||
[inline]
|
[inline]
|
||||||
pub fn abs<T>(a T) T {
|
pub fn abs<T>(a T) T {
|
||||||
return if a > 0 { a } else { -a }
|
return if a < 0 { -a } else { a }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue