v / vlib / math / floor.js.v
34 lines · 26 sloc · 695 bytes · 757929392e0e7a75fc1272116460981e589737d5
Raw
1module math
2
3fn JS.Math.ceil(x f64) f64
4
5fn JS.Math.floor(x f64) f64
6
7fn JS.Math.round(x f64) f64
8
9fn JS.Math.trunc(x f64) f64
10
11// ceil returns the nearest f64 greater or equal to the provided value.
12@[inline]
13pub fn ceil(x f64) f64 {
14 return JS.Math.ceil(x)
15}
16
17// floor returns the nearest f64 lower or equal of the provided value.
18@[inline]
19pub fn floor(x f64) f64 {
20 return JS.Math.floor(x)
21}
22
23// round returns the integer nearest to the provided value.
24@[inline]
25pub fn round(x f64) f64 {
26 return JS.Math.round(x)
27}
28
29// trunc rounds a toward zero, returning the nearest integral value that is not
30// larger in magnitude than a.
31@[inline]
32pub fn trunc(x f64) f64 {
33 return JS.Math.trunc(x)
34}
35