本帖最后由 zorsite 于 2017-5-31 03:15 编辑 - d2 a: p$ K. X; d1 c! P. w. _. `
4 ~" y* V: J8 {+ t" w! nceil1 a" U2 h& R6 q. u
(num num) 天花板,向上取整。 Example double myval =ceil(2.3); // Sets myval to 3.
) J2 Q8 U$ p# c- e$ [. Idouble myval = ceil(3.8); // Sets myval to 4. $ J/ S. a8 L) s
double myval = ceil(-2.3); // Sets myval to -2. 7 o2 H' U) u* E/ H/ t% A
double myval = ceil(-3.8); // Sets myval to -3. / @& ?0 Z/ n- D; n* Y/ o, r
1 Q, z; t6 p. o% y' u floor
% y2 _4 x5 u. y' _5 p; c7 J- C, O(num num) 地板,向下取整。 Example double myval = floor(2.3); // Sets myvalto 2. 2 |4 ]. x$ K W1 i! e) p
double myval = floor(3.8); // Sets myval to 3. & C; u& [( n' P2 T+ m4 |& n
double myval = floor(-2.3); // Sets myval to -3. O1 M) J$ {) ?
double myval = floor(-3.8); // Sets myval to -4.
5 s& L3 F t- x+ `+ X* b) }
* p, }( C" x3 f1 ^ a# k* C8 x) T round$ ?& p) c* q4 S2 m0 z9 e
(num value[, num precision]) 根据指定的小数位数进行四舍五入。 Example int mynum1 = round(3.6269);
; r4 q# `% v4 |; w) ?3 }+ D$ jint mynum2 = round(3.6269,2);
* a+ S- U. ]2 d7 ?$ v* `. h2 H
8 ~! J2 u4 C3 V( U. G9 Imynum1 will be 4, and mynum2 will be 3.63.
4 w7 ^7 l- f! ^+ B- M
' @, ~1 c0 D, ?, C( K# X/ j trunc
. I* b5 O6 n& a(num value) 去除小数部分取整。Truncation Example trunc(2.478), returns 2
. V: k5 g4 v- E+ P: @3 T/ L) T
! J; h3 r" T; S0 gtrunc(2.95), returns 2
% `7 ?* T$ b6 q# v frac
+ f9 ^2 W( R- L$ I. W! p3 H% t! Y(num value) 取小数点之后的部分。 Example frac(3.124) returns 0.124
6 u: N9 b: j' Y0 j, Lfrac(-16.12) returns -0.12' }* z" ]4 v) G& r+ i. N; n2 H1 v
frac(12) returns 0.0
$ I+ \ U7 ?2 y0 X. o
8 F4 N" ?* ?0 Y sign! y6 h- n) U- L' @% u- O' d
(num value) 决断正负零,正数返回1,负数返回-1,0返回0。 Example sign(-1)
& Y+ H7 ~) O! Y( r5 _1 s4 P% o/ M' P
fabs% l) A- \/ |% C$ d3 n
(num value) 绝对值。 Example if(fabs(x1 - x2) > 5) / j" W' ^# `9 l0 z- I5 m
2 Y& x% c* Y* W. ]9 K
factorial
1 @: H6 H3 v" n1 l(num value) 阶乘。 Example factorial(5)
1 T4 s8 X7 Y& X" l7 R
" {( A9 f5 s' kThis calculates the factorial of 5, which is 1*2*3*4*5 = 120
) f: A8 V, @4 y3 l% M
) _5 a& ?' R d fmod2 U8 J0 ~ L/ P, C/ H% p3 x1 `
(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.
& H0 f8 W5 ?0 Q: D4 F8 X, |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
' d: \* ]8 u- r- I; W0 w7 u0 A! x
4 R* h4 h4 k4 B5 Z% `) Sif(fmod(current.stats.output,10) == 0)
; R: r9 Z4 B. p2 y
& h# u3 D4 g. d3 q% X- R. LIf 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. 4 \- P" ?6 v0 k! S6 [
2 _& E Z$ F- Z% |$ V" | pow
6 ]7 L+ ^$ M0 t; N(num num1, numnum2) 乘方。 Example double myval = pow(2,3); Sets myval to 8.
B1 T( E8 A" N. \1 i W1 r0 D& p: \1 m5 C
sqr" H- U* _' _1 ?- S1 o" q5 ?+ D3 H
(num value) 平方Square of value. Example sqr(2)
* m* s) s4 `# G% k" { w, G7 X! c5 R! k
sqrt
. r) m5 z2 A9 V7 ^# f/ u; K5 c(num value) 平方根Square root of value Example sqrt(10) This expression will return 3.16
' u# m$ w) M8 [% N; _% d
( \6 v8 w' g2 A1 j6 {! ^! ^, S
+ M, P9 v7 W3 C+ F& M+ D, B* W比如,我们要计算托盘上有多少层货物。7 o$ G( I- @' T" f) B! g7 R( g; s
默认情况下,pallet上面每层可以放置4个box。也就是说,1,2,3,4个box都算1层,5,6,7,8个box都算是2层。
1 ?. a: \+ G1 F3 T此时可以用ceil函数向上取整,ceil(content(pallet)/4)即可得到正确的层数。 " N3 a1 \5 G+ x6 o1 u- b
|