UNPKG

745 Btext/coffeescriptView Raw
1### ceiling =====================================================================
2
3Tags
4----
5scripting, JS, internal, treenode, general concept
6
7Parameters
8----------
9x
10
11General description
12-------------------
13
14Returns the smallest integer not less than x.
15
16###
17
18
19Eval_ceiling = ->
20 push(cadr(p1))
21 Eval()
22 ceiling()
23
24ceiling = ->
25 save()
26 yyceiling()
27 restore()
28
29yyceiling = ->
30 d = 0.0
31
32 p1 = pop()
33
34 if (!isnum(p1))
35 push_symbol(CEILING)
36 push(p1)
37 list(2)
38 return
39
40 if (isdouble(p1))
41 d = Math.ceil(p1.d)
42 push_double(d)
43 return
44
45 if (isinteger(p1))
46 push(p1)
47 return
48
49 p3 = new U()
50 p3.k = NUM
51 p3.q.a = mdiv(p1.q.a, p1.q.b)
52 p3.q.b = mint(1)
53 push(p3)
54
55 if (isnegativenumber(p1))
56 doNothing = 1
57 else
58 push_integer(1)
59 add()
60
61