本帖最后由 zorsite 于 2017-5-31 03:15 编辑 ; [0 p; V1 F5 b! N% }! \% S# Z4 b
9 j- w+ \7 v! X
ceil
2 t+ V" D( ], w& ~2 _& L(num num) 天花板,向上取整。 Example double myval =ceil(2.3); // Sets myval to 3.
+ L: [) ^! v/ b8 a5 y$ |5 `7 L. wdouble myval = ceil(3.8); // Sets myval to 4. 4 @# m9 w0 Z2 R3 H$ q% L
double myval = ceil(-2.3); // Sets myval to -2. - M0 u& O& H) t% {- o9 [
double myval = ceil(-3.8); // Sets myval to -3.
% h# f9 ^5 W) t( H
6 \( q$ {" U J, N1 x7 R* L9 d* x( A floor
2 i" L0 k4 M2 l$ V- ?(num num) 地板,向下取整。 Example double myval = floor(2.3); // Sets myvalto 2.
3 ~$ i9 M1 R0 odouble myval = floor(3.8); // Sets myval to 3. 8 g& s' ~2 }8 U: [' V& O: u
double myval = floor(-2.3); // Sets myval to -3. 8 F( L/ J+ o/ \2 t$ n( x. Z% m( V
double myval = floor(-3.8); // Sets myval to -4. ) u. ^( p6 O; c" f+ t
5 x0 v4 m, m! n0 Y' e# D. f* [ round
0 H) n; Z) ~* h6 S* b(num value[, num precision]) 根据指定的小数位数进行四舍五入。 Example int mynum1 = round(3.6269);
U9 g7 Y3 ^6 i& v8 |9 xint mynum2 = round(3.6269,2);
) y( k6 P" P' }- t) w5 K) N2 a- w" j! Q( b& `/ z$ ?0 V, k
mynum1 will be 4, and mynum2 will be 3.63.
& f( b2 {4 \7 g& C: `5 X: _0 ~7 v# U% N' V. V
trunc
2 Q8 R( C9 K5 Y(num value) 去除小数部分取整。Truncation Example trunc(2.478), returns 2
# C& e; w `, K( H* {1 R: t V% a9 w$ T- e0 w" _
trunc(2.95), returns 2
1 M6 h3 ^$ x4 N# V# Q frac. D* E& r0 C: d$ l* t
(num value) 取小数点之后的部分。 Example frac(3.124) returns 0.124/ E. b5 m' w7 K1 }, V6 T- {5 ?
frac(-16.12) returns -0.12% A8 x* Q0 m# d7 b/ W
frac(12) returns 0.0 6 t- {8 h. J; \0 g" l3 n# ^: m; P
8 \- [/ |8 q ]2 N8 L9 J. d
sign
/ D0 |8 i; q5 u6 G7 L2 \9 Z7 ^$ c(num value) 决断正负零,正数返回1,负数返回-1,0返回0。 Example sign(-1) 7 R; H2 s8 f' K) R3 d9 ~
7 v# J: b3 Q; b% m
fabs
* Q* r3 |( s9 a4 [: a& r(num value) 绝对值。 Example if(fabs(x1 - x2) > 5)
. x0 i" {' q* r
9 m( {% W" N) n. [ factorial( i o. _+ S: B' W
(num value) 阶乘。 Example factorial(5) - Y2 B* @! L4 u
8 M, f3 |# J* H2 B8 P
This calculates the factorial of 5, which is 1*2*3*4*5 = 120
8 L' i i* r; r1 C/ Z0 K
: [/ d# w+ r) | fmod
4 P# r+ [% h( e K(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.
( Y2 P7 R0 I2 G6 }% A: ~8 [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
, J7 X, e! V4 ]* N) D' w; B+ k; Q- @
if(fmod(current.stats.output,10) == 0)
% i' V6 \* d7 g* M7 c
* k# H$ i! A# E. k! P {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.
. @) P- w$ T& p" o, z. H! F2 o+ z$ @+ o! w; A
pow
' R7 Q2 ~! H B1 G: [9 C(num num1, numnum2) 乘方。 Example double myval = pow(2,3); Sets myval to 8.
" }# L+ ^! g" @$ v! |# S* ] e) Y. l- _ ~' r1 p- o' Q
sqr3 V2 }& i) P7 J& _6 G+ @
(num value) 平方Square of value. Example sqr(2) . X7 s7 W4 B# Y8 J( y& @, N
. [& C7 {3 b9 V: T. n sqrt" a& K5 ^3 Q8 ]$ m6 w
(num value) 平方根Square root of value Example sqrt(10) This expression will return 3.16 $ ]% `( v3 q- a: q$ Q: H u/ G
1 n; I1 n3 ]" u0 n
& j. R1 n1 x9 d% x! |' z比如,我们要计算托盘上有多少层货物。
/ l3 E% J0 F" I# ^: S' |, _默认情况下,pallet上面每层可以放置4个box。也就是说,1,2,3,4个box都算1层,5,6,7,8个box都算是2层。2 b7 |; ^ s& a, x9 t0 K. \
此时可以用ceil函数向上取整,ceil(content(pallet)/4)即可得到正确的层数。 7 M0 W- v; f: S* a# F
|