本帖最后由 zorsite 于 2017-5-31 03:15 编辑
8 o, c5 J) ^5 Z% l H: c& ^2 {; a3 [! z& J& t: v/ J3 h1 k
ceil# v7 m- n6 u& s
(num num) 天花板,向上取整。 Example double myval =ceil(2.3); // Sets myval to 3. / h) a, c2 { t" n, l5 \) X* A8 `
double myval = ceil(3.8); // Sets myval to 4.
, @, U B F. J, T( S, qdouble myval = ceil(-2.3); // Sets myval to -2.
2 y1 U* g& c0 f5 o, v/ }double myval = ceil(-3.8); // Sets myval to -3.
2 x$ {; b6 R9 S+ j+ O; `# R, p2 |7 g3 H; s) T+ Z. j/ ?
floor
( ^0 y6 {7 P% D: R0 u) q(num num) 地板,向下取整。 Example double myval = floor(2.3); // Sets myvalto 2.
$ i. U1 U1 M5 B1 T* \double myval = floor(3.8); // Sets myval to 3. * d6 g6 ~7 Z' @& V, b
double myval = floor(-2.3); // Sets myval to -3. . x! c/ U/ _0 f3 Q
double myval = floor(-3.8); // Sets myval to -4. 5 R' W7 ~" U+ A
7 S2 W* w$ j' o( M( T/ y
round
: w& k: @! {7 h# K9 b3 g(num value[, num precision]) 根据指定的小数位数进行四舍五入。 Example int mynum1 = round(3.6269);( w" k S& t# }3 Q7 o+ S
int mynum2 = round(3.6269,2);& c6 V2 _$ I, _: z7 J/ `( H3 O
! Z+ v) V- ]) @9 N% T# T. @1 gmynum1 will be 4, and mynum2 will be 3.63. ' _+ O& r; E8 `
: z+ h, c' I8 M8 X! U. L
trunc0 B, \ l; E1 f5 i7 k
(num value) 去除小数部分取整。Truncation Example trunc(2.478), returns 2
5 `& v& y! p* G, C3 [4 A
4 I& k$ Z" ]8 Y' l$ |; w; O7 }! N! Ftrunc(2.95), returns 2; ~8 `* ~% r$ U& M2 u! t: r( C9 [& y1 A
frac+ I) k* a' \2 L
(num value) 取小数点之后的部分。 Example frac(3.124) returns 0.124
3 f- n. Z5 U | c" M. }0 U; ^" ~frac(-16.12) returns -0.12
2 w* E A; y; Q L! g4 Ffrac(12) returns 0.0
: {0 {" X, P4 z5 l3 {4 o: p4 Y8 x3 M# ]/ `; `5 ~2 [. y
sign8 [* G$ g& q! n/ f' \
(num value) 决断正负零,正数返回1,负数返回-1,0返回0。 Example sign(-1) " d8 z! S7 E$ g2 T
3 T; c7 d4 r R- W( {
fabs
" _; g0 N/ Z) t8 u7 q(num value) 绝对值。 Example if(fabs(x1 - x2) > 5) - f4 _1 |# p6 L! h* Z
- W% A/ B# q9 k! ?8 _& S' R: [( J
factorial6 t8 T& l- }, K9 k
(num value) 阶乘。 Example factorial(5)
" ?* ~$ v5 i" ]1 r% X6 F. r0 Z( a( c, q
This calculates the factorial of 5, which is 1*2*3*4*5 = 120
/ f; l0 g9 ~% H/ k9 g' \
3 b7 t( j4 D2 u' V: e% \ fmod
4 K& E9 X: P6 c: Q(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.* q# R0 e# o) S1 R. l D9 K
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; l+ O9 L9 I2 x' t; g" ]
) c( j5 \/ u: b2 P# w% D
if(fmod(current.stats.output,10) == 0)
/ r5 b+ M' X/ _- ~4 Q1 `4 N( [! \8 B+ W4 j$ 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.
t7 F/ T0 X! e0 G$ m$ i5 e; M. ]/ m4 v$ U) _ j+ n( s
pow
2 B& H% [3 x6 J+ P(num num1, numnum2) 乘方。 Example double myval = pow(2,3); Sets myval to 8.
+ @! I; y: _ B
5 t9 l; ]) X; Z2 k8 a1 F sqr
: h+ O% v. s# e(num value) 平方Square of value. Example sqr(2) 7 P4 t& O3 ?! c
) @: B' |9 Q# v& n( Z2 m3 `+ a8 i sqrt7 V/ }. P! m3 G# `/ b; ]
(num value) 平方根Square root of value Example sqrt(10) This expression will return 3.16
+ k- W! S8 ]2 o" C/ Q
" t1 @6 P/ D$ f6 \- M3 a( T% y3 c
比如,我们要计算托盘上有多少层货物。
3 z: U+ r. y/ k默认情况下,pallet上面每层可以放置4个box。也就是说,1,2,3,4个box都算1层,5,6,7,8个box都算是2层。
) n( ?- x1 n! A% ?6 D此时可以用ceil函数向上取整,ceil(content(pallet)/4)即可得到正确的层数。 7 s5 ^8 P4 T- d" @3 b& N2 n
|