本帖最后由 zorsite 于 2017-5-31 03:15 编辑 2 A5 W3 H4 U ]9 i5 y
$ Y1 ^: y, I2 P& w, S
ceil* y m' G& d* G) g" L& i8 v4 \
(num num) 天花板,向上取整。 Example double myval =ceil(2.3); // Sets myval to 3.
! Z9 |+ @, G7 A' p3 ]8 `double myval = ceil(3.8); // Sets myval to 4. ( H7 T$ k0 U% |) R
double myval = ceil(-2.3); // Sets myval to -2.
2 f m/ r2 `7 F0 {& ?- {double myval = ceil(-3.8); // Sets myval to -3. % D4 r! e5 }0 ]( B M) \' v
8 N/ O9 Y5 d" |: x0 u
floor( ]4 ^- W: `5 Y/ |4 w1 C- x
(num num) 地板,向下取整。 Example double myval = floor(2.3); // Sets myvalto 2. & e J5 k# C/ l2 ~7 v( {
double myval = floor(3.8); // Sets myval to 3.
/ s% e: |! o" ^# b/ Ydouble myval = floor(-2.3); // Sets myval to -3. ) U! K K1 f+ ]* Z
double myval = floor(-3.8); // Sets myval to -4. % c ^0 `) X; ?9 ^& c8 X
9 o3 [* \: t: n4 a# P round& ] ]+ q% U7 l9 }( ?) Z' A! T
(num value[, num precision]) 根据指定的小数位数进行四舍五入。 Example int mynum1 = round(3.6269);1 g' B; x" p# y
int mynum2 = round(3.6269,2);
) Y; N0 X" H( r# [) C4 i9 e# d3 m' P- }
mynum1 will be 4, and mynum2 will be 3.63. 6 f4 z" O1 F- ]! A" g
3 ~% S/ F3 n( a( f6 B3 @0 K; [ trunc
; b+ N6 }; ^4 r+ H(num value) 去除小数部分取整。Truncation Example trunc(2.478), returns 20 Z" t( f5 @* {% r
7 o& a* O: q' [+ x/ o7 Jtrunc(2.95), returns 26 D+ P2 \+ f6 b6 n
frac
# u0 ]4 K7 V" b8 E2 |(num value) 取小数点之后的部分。 Example frac(3.124) returns 0.1242 Z) u9 S) M2 q( p& W7 i5 o
frac(-16.12) returns -0.12
1 L3 I; f$ B% x' H* s4 Hfrac(12) returns 0.0
+ D7 k' f! K/ j# v# P4 p$ s9 ?5 c/ @& N: U0 y# w% F
sign( ?/ B7 {: N8 v& d* q6 D
(num value) 决断正负零,正数返回1,负数返回-1,0返回0。 Example sign(-1) . h ~5 V# ~; J+ S9 m
4 c: R" N: A% K
fabs1 I' k% P# @0 h$ p% G
(num value) 绝对值。 Example if(fabs(x1 - x2) > 5)
9 V5 R4 b6 y Y7 _ d3 Q& `0 b+ V% e/ O: V6 b
factorial* B$ v) z8 o6 _) u
(num value) 阶乘。 Example factorial(5)
* a5 t* p( ^+ B3 d$ h' i/ S; J
, r3 h* T! |8 q1 T! f* k; `1 ]This calculates the factorial of 5, which is 1*2*3*4*5 = 120 * Z7 y l2 V6 y- a+ A& n0 I4 Q
?$ Y! z' D! ?# i, e& b" ?$ ~ fmod- _) O9 E7 y) {( f; 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.
* ]) G3 }4 e/ x( P; tThis 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
' {- \% C& m4 B- Q. Y
) `% W+ }5 l! Y: Dif(fmod(current.stats.output,10) == 0)
- K2 H, N! g! w- p, i) b4 k, e1 i0 ?/ |+ S
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.
. O6 T" i! p- x3 a) @: G7 n: Z( h: S2 O8 r, J6 f/ R& }3 k% ]" Y
pow4 [. t2 E6 H5 y+ x( ~. A P
(num num1, numnum2) 乘方。 Example double myval = pow(2,3); Sets myval to 8.
* q: z4 I+ E+ ~/ d& K2 X8 J& U2 t+ J* R" Y( \2 B
sqr$ A- l8 @' ?* F1 o/ C& ~) ?
(num value) 平方Square of value. Example sqr(2)
4 u8 T t+ {* X1 p$ K8 s$ s% c0 _8 D0 ?, y7 h
sqrt
3 U) S8 Z; h$ H5 E0 n(num value) 平方根Square root of value Example sqrt(10) This expression will return 3.16 & ?6 E( O u+ S" W# |
) f! G( T1 |2 D& l
: ?: h% G' q# i0 {" a5 K; l( H比如,我们要计算托盘上有多少层货物。
: T3 B3 c+ t- ]- c8 Z默认情况下,pallet上面每层可以放置4个box。也就是说,1,2,3,4个box都算1层,5,6,7,8个box都算是2层。9 M# W C5 T6 U+ t- x
此时可以用ceil函数向上取整,ceil(content(pallet)/4)即可得到正确的层数。 # g' o2 M$ e! U/ `- e: j( Y
|