本帖最后由 zorsite 于 2017-5-31 03:15 编辑 # c! y# w8 V! a" V, ]0 W
3 x/ c% O$ C- p2 |5 C8 U
ceil, N4 q# w( ` a$ D
(num num) 天花板,向上取整。 Example double myval =ceil(2.3); // Sets myval to 3.
5 A, m, H4 v4 F- I* jdouble myval = ceil(3.8); // Sets myval to 4.
" g# f4 }+ D- l* {- sdouble myval = ceil(-2.3); // Sets myval to -2. 8 I" h; i7 v: d, V- j1 M
double myval = ceil(-3.8); // Sets myval to -3.
; ^0 r, e+ [1 {# \1 _1 y% I) ]0 q2 d/ U( I) N
floor
5 a0 |: q8 z ^# ](num num) 地板,向下取整。 Example double myval = floor(2.3); // Sets myvalto 2. " f8 d2 n# A( {0 y
double myval = floor(3.8); // Sets myval to 3. % V/ e1 p: o: {0 z" g' z G
double myval = floor(-2.3); // Sets myval to -3. + T8 Q: b5 m# @/ Z- S
double myval = floor(-3.8); // Sets myval to -4.
# O4 t% O5 @9 p$ U" m9 L! } Z' I1 F0 J3 o, C" E% d: b
round, C3 x0 `9 C6 F2 f2 z
(num value[, num precision]) 根据指定的小数位数进行四舍五入。 Example int mynum1 = round(3.6269);0 [/ l; W8 T0 ?( F; B6 M
int mynum2 = round(3.6269,2);
+ @: y, u! @5 b
. c2 j# K% o8 n; S2 ]" q+ n/ Dmynum1 will be 4, and mynum2 will be 3.63.
9 j3 F+ w/ A3 Y
- e0 p, E i% g, k! P trunc
! k5 ]1 i W" a q(num value) 去除小数部分取整。Truncation Example trunc(2.478), returns 2
+ g0 V. d( \) D3 z4 i0 z; g7 G
& F+ q( A0 m2 _, _- [trunc(2.95), returns 2 c4 v1 Z1 v1 ~" v
frac: [/ v) s* p. c
(num value) 取小数点之后的部分。 Example frac(3.124) returns 0.124# n- Q! w1 b' z) O8 e, n
frac(-16.12) returns -0.12
8 t# u9 Y; }- U+ G2 b7 @/ ?/ Mfrac(12) returns 0.0 9 p+ c- ~/ a- J2 r! b0 R! h
% Z X K( ]! Z; t sign1 u2 X8 g8 |: U
(num value) 决断正负零,正数返回1,负数返回-1,0返回0。 Example sign(-1) 4 u0 m/ d# X& j' i7 T5 X" D! [' X
+ ~% t7 J+ H1 J7 k# P fabs# ?! G; ?9 G2 n8 L# g/ y
(num value) 绝对值。 Example if(fabs(x1 - x2) > 5) . z1 F! w- M1 ^9 j1 V
4 \3 R! E2 F1 v
factorial
) ]/ R9 `4 u& I0 X(num value) 阶乘。 Example factorial(5) + \9 E1 z8 A( X |4 x# w) U
4 I: s. ^ m' r$ L
This calculates the factorial of 5, which is 1*2*3*4*5 = 120
: X5 |/ F6 M1 M4 E2 ?+ g; J H. [; ]6 D( r' k
fmod
+ ~8 H' y V0 P% v8 j; m G: I1 Z(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.) j' ^3 o: ]: P: X# |; b o
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/ h/ V* H7 h, ~) N3 ^& U
5 A' N# R& a. @- o6 y4 v* bif(fmod(current.stats.output,10) == 0)
6 p: }5 H( w+ o) s( x$ i: B! H0 P" a* 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.
" @) S- x' a3 l) l9 J) f+ X. ]
! V6 I. j! e- |4 o- G pow* v, R! [) _/ D& X
(num num1, numnum2) 乘方。 Example double myval = pow(2,3); Sets myval to 8.
) @! C1 E* r+ e/ L1 n: \4 B
+ `) u; K: R0 j5 f: e sqr
, u: ?0 t+ F( F# H j(num value) 平方Square of value. Example sqr(2) f8 Z+ U" S/ a3 C
`$ y8 ?9 F% z- g1 ~ sqrt2 n$ I$ [: k/ U# J- A
(num value) 平方根Square root of value Example sqrt(10) This expression will return 3.16
. p6 R) d" i- g7 i, ^$ W& ?6 S4 W. {; `* C3 j) u7 r
# b, L* Y& d0 }, f% W- C
比如,我们要计算托盘上有多少层货物。* a) g: m. y9 |" O
默认情况下,pallet上面每层可以放置4个box。也就是说,1,2,3,4个box都算1层,5,6,7,8个box都算是2层。
0 f# ]! E: X5 B) y5 a此时可以用ceil函数向上取整,ceil(content(pallet)/4)即可得到正确的层数。
# _, _( P! l" R
|