mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
This commit is contained in:
parent
752e105f25
commit
82ac39eca6
@ -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
Block a user