本帖最后由 zorsite 于 2017-5-31 03:15 编辑 9 o8 l( k) E9 v( p6 ]: l+ t7 s, R
; {) {2 R" ^5 K( D5 s h+ Z: _
ceil9 z( ]5 E+ M7 F8 a. i6 s
(num num) 天花板,向上取整。 Example double myval =ceil(2.3); // Sets myval to 3. 5 X* [: W$ l' R- F
double myval = ceil(3.8); // Sets myval to 4. : T5 o4 {+ G3 ~4 u9 G' M
double myval = ceil(-2.3); // Sets myval to -2. 5 }3 V H" ]' j. S- ]
double myval = ceil(-3.8); // Sets myval to -3.
- K; h0 Q" j) b) \1 \" m4 y/ K% q. }* y. O; p; U# L
floor
/ J( ]# ?0 V/ e/ i. z* p(num num) 地板,向下取整。 Example double myval = floor(2.3); // Sets myvalto 2. # c6 i6 c- W, U+ q7 V
double myval = floor(3.8); // Sets myval to 3. 5 p0 k/ [& h" [* a3 U/ `; _) C" \
double myval = floor(-2.3); // Sets myval to -3. $ Z e5 } R3 d/ M
double myval = floor(-3.8); // Sets myval to -4.
3 U. ?. ^& e" J
/ ~0 ]6 Y- _2 K% ^) \" Q round
4 ^ J$ k, \9 E% n; v$ z: q' S(num value[, num precision]) 根据指定的小数位数进行四舍五入。 Example int mynum1 = round(3.6269);
9 U0 M$ ?% R) Q! X6 [5 C, ]int mynum2 = round(3.6269,2);
/ F, ? o+ g4 P9 Y( [# @9 G* _; }* j0 p
mynum1 will be 4, and mynum2 will be 3.63. ) m$ }* J! V0 x: Q2 p
! {( Y o6 Q* t0 D; Z. ~
trunc
) `+ g* u% S( m' S9 _6 |8 D- A) Z" V- ~(num value) 去除小数部分取整。Truncation Example trunc(2.478), returns 2
5 }) l; G9 t0 m+ }" Y6 Y
3 [' {% n8 ?' Q3 T' L4 X* dtrunc(2.95), returns 2; m; O2 e% f6 E% Q t
frac! e) e1 H$ z: _+ p
(num value) 取小数点之后的部分。 Example frac(3.124) returns 0.1243 t5 y9 n1 m$ L' ~% U' z7 M# @/ n# V
frac(-16.12) returns -0.12% s3 ?) m' j# _9 P
frac(12) returns 0.0 6 a q9 W) _/ @$ J8 g' m, M
, C- ^7 s% r3 Y2 U
sign1 T& b; M6 ?8 y v' K$ P! I! m) y
(num value) 决断正负零,正数返回1,负数返回-1,0返回0。 Example sign(-1)
8 H% \8 o4 L$ t8 k) b3 U' o7 l# H/ `5 ]$ F6 Z0 L8 O6 U
fabs+ S0 x& V% u/ g
(num value) 绝对值。 Example if(fabs(x1 - x2) > 5) # t N! { V+ X4 A8 K: J) F
4 ]0 W# ~; D/ i& s
factorial; O$ ^( d% b; _0 u ^4 b$ e2 S0 B
(num value) 阶乘。 Example factorial(5) ( Y C+ ]* K8 p- c: v
Q F& a f& c' \0 i( \
This calculates the factorial of 5, which is 1*2*3*4*5 = 120
. L) x5 K5 c' b' z
3 v! I* Z5 V; n- U/ f& V fmod
3 z/ j; g, N) s/ d; k* N" x2 x6 P9 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.# i* h9 t. X9 L/ h9 B- E
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
& \4 E+ ^8 E7 q3 K% y4 x8 h
! z2 c' h. i: w/ p1 V, w( F2 F! Iif(fmod(current.stats.output,10) == 0)3 V% U5 ]- P& X. R/ M! ~
8 s0 J& j: v8 _& f
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. 3 Y8 _- @5 W7 a1 L; ^7 M% N
) ^+ r: t! {# r: N# S. d; r( G6 i pow
8 E2 Y2 ]# v8 d' r2 ^3 v(num num1, numnum2) 乘方。 Example double myval = pow(2,3); Sets myval to 8. ) v3 j: M! Z, ?3 m- [( V0 ]7 k, u
P: I! t- X. t4 S; t
sqr, g: {0 t, l8 g8 z2 }
(num value) 平方Square of value. Example sqr(2)
+ A: N5 Z0 B9 s7 P0 u3 A; ?1 T; j, Y. x; @" l
sqrt7 P% T/ j- z# D. C% V+ r; B& W4 v! [
(num value) 平方根Square root of value Example sqrt(10) This expression will return 3.16
' _- B' I! ~+ c, P% |( I* F5 R
" X/ D+ R- Q% ]! k5 P& ], x0 U4 V3 R( p
比如,我们要计算托盘上有多少层货物。
3 r# h+ O' U% r/ u1 u, k默认情况下,pallet上面每层可以放置4个box。也就是说,1,2,3,4个box都算1层,5,6,7,8个box都算是2层。; P# T4 `! K& r+ v9 r) X5 u
此时可以用ceil函数向上取整,ceil(content(pallet)/4)即可得到正确的层数。 ; k; U) d" b- Z% q' G$ K
|