本帖最后由 zorsite 于 2017-5-31 03:15 编辑 2 v% z* e* n1 S6 y- D+ y
/ F: v* I$ b7 M4 a+ t% q1 fceil
V, G4 U0 O# Q& W; y4 }(num num) 天花板,向上取整。 Example double myval =ceil(2.3); // Sets myval to 3.
! F. `" h6 X- @9 T" v/ ddouble myval = ceil(3.8); // Sets myval to 4. ; U7 d8 y* [- O' q$ I
double myval = ceil(-2.3); // Sets myval to -2.
$ ~4 C# o3 ?7 P6 A8 hdouble myval = ceil(-3.8); // Sets myval to -3. # g. N2 b$ O |' L8 Q
* J. f, o/ j( A; c2 c/ H8 h
floor
R( ? O9 C/ E( F9 K(num num) 地板,向下取整。 Example double myval = floor(2.3); // Sets myvalto 2. 5 d$ J5 ]4 P! ~; x
double myval = floor(3.8); // Sets myval to 3.
4 b+ V9 [ z. ~. @% d& Cdouble myval = floor(-2.3); // Sets myval to -3.
7 P* V0 T3 A0 e) `9 H; |double myval = floor(-3.8); // Sets myval to -4. ) O: H t1 N. _
- h9 A6 `* x. w; V: S
round
- y+ x5 Q& j: c6 g8 V: I(num value[, num precision]) 根据指定的小数位数进行四舍五入。 Example int mynum1 = round(3.6269);
8 F# B3 h3 t& Y- Tint mynum2 = round(3.6269,2);
: B$ c. h0 D& s" b9 U) r1 K) f( K* Q
mynum1 will be 4, and mynum2 will be 3.63.
+ G0 t/ o% i8 J3 Q" u3 o$ v% e2 \: t7 \; i, K( m+ X- d. e
trunc3 [" i, {9 d# K9 Y
(num value) 去除小数部分取整。Truncation Example trunc(2.478), returns 25 h; O, I: D+ M+ j4 j+ U: H% i
4 c; d& v5 s; {) y4 R) ?) ytrunc(2.95), returns 2
8 A( h* B2 D. P frac
3 s, |' R/ t4 [% _% i(num value) 取小数点之后的部分。 Example frac(3.124) returns 0.124
# I; ?" z" @1 P: n2 _frac(-16.12) returns -0.12 _- E; z5 i" N& N4 C( r
frac(12) returns 0.0
( X" W" ?: T( g* N! `7 m6 m* n1 R( J" J# w
sign
+ p/ z8 t' x" v, \: w" b; [2 I; Y(num value) 决断正负零,正数返回1,负数返回-1,0返回0。 Example sign(-1) ( B2 s3 R p3 s
6 b1 t0 t( V' R4 d7 c% g5 B fabs* P& `% u& q) W' P' o
(num value) 绝对值。 Example if(fabs(x1 - x2) > 5)
/ _7 h2 `; j( w3 z) E, d" v& ^# K' a* X" F7 k Y- a
factorial# X: j5 l8 M3 v9 s# a2 B9 P
(num value) 阶乘。 Example factorial(5)
3 E+ R( n) }) o4 R/ R. K( `2 x: q: Z9 w! L" @0 M+ t9 B' i
This calculates the factorial of 5, which is 1*2*3*4*5 = 120 + |3 P) Q: K. s
% Q# L' @2 b' M1 `/ A e fmod! Q2 t8 j; a5 D2 N6 p! ^
(num value1, numvalue2) 取余。 Description Remainder of value1/value2. fmod returnsthe floating-point remainder of value1 / value2. If the value of b is 0.0, fmodreturns a quiet NaN.2 \5 f! Z, J, f
This command is great for getting a repeating set ofnumbers because no matter what value1 is, so long as value2 is unchanged, fmodwill return a set of numbers that keeps repeating itself. Example fmod(10,3) This returns the remainder of 10/3, which is 1.0! G. `( U, J; t5 r) O* E. n& B
! x9 Z ~+ P. ^if(fmod(current.stats.output,10) == 0)
/ u( o- D' H( n" S7 n8 q* }- X) ]7 S1 y+ d0 f& c
If this condition was in the OnExit of an object in the model, it would be truewith every 10th flowitem that exits, starting with the 10th flowitem. - Y% i/ @" u+ k" f
* C$ R2 ]5 c3 |' r7 N" Z7 N pow5 X6 q" [" Y0 h5 x9 q/ S
(num num1, numnum2) 乘方。 Example double myval = pow(2,3); Sets myval to 8.
' h1 r7 H6 b q. G$ i$ O) _8 H8 t
2 D6 f \" S9 q- d sqr
( e2 _4 L: {/ ~2 Y$ D(num value) 平方Square of value. Example sqr(2) " d/ G4 U* ^0 o9 ^3 V1 {& t d
% H* Q2 ?; b' j, u sqrt& e6 @1 T6 H; r& y3 ~& V& V
(num value) 平方根Square root of value Example sqrt(10) This expression will return 3.16 ) w4 _1 C* o. A5 b S% K+ y- Y7 X
# `4 C1 U2 u- a8 t- N; Z1 Z; E5 a
# p9 A& Z/ F6 F+ j
比如,我们要计算托盘上有多少层货物。
" G7 p& P# `8 {# l' i' g默认情况下,pallet上面每层可以放置4个box。也就是说,1,2,3,4个box都算1层,5,6,7,8个box都算是2层。( {$ n/ A8 w: Y+ f v3 Q, ]
此时可以用ceil函数向上取整,ceil(content(pallet)/4)即可得到正确的层数。
6 C) P$ d" u( V4 e' u9 {' n6 `
|