1 | ### ceiling =====================================================================
|
2 |
|
3 | Tags
|
4 | ----
|
5 | scripting, JS, internal, treenode, general concept
|
6 |
|
7 | Parameters
|
8 | ----------
|
9 | x
|
10 |
|
11 | General description
|
12 | -------------------
|
13 |
|
14 | Returns the smallest integer not less than x.
|
15 |
|
16 | ###
|
17 |
|
18 |
|
19 | Eval_ceiling = ->
|
20 | push(cadr(p1))
|
21 | Eval()
|
22 | ceiling()
|
23 |
|
24 | ceiling = ->
|
25 | save()
|
26 | yyceiling()
|
27 | restore()
|
28 |
|
29 | yyceiling = ->
|
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 |
|