本帖最后由 zorsite 于 2017-5-31 03:15 编辑 % q/ W; E i$ G
: t* L% M S2 }* q) |/ a
ceil
4 I6 R$ p, d0 B2 I0 c(num num) 天花板,向上取整。 Example double myval =ceil(2.3); // Sets myval to 3.
3 d8 [ u/ [* v* L/ |double myval = ceil(3.8); // Sets myval to 4. 0 C' X2 d2 s3 K7 I9 ~9 |
double myval = ceil(-2.3); // Sets myval to -2. + t( `/ W. z, F/ N! O/ t, A( m
double myval = ceil(-3.8); // Sets myval to -3. ; M' H$ d! s+ s9 d5 ?% J3 j3 Q m- e
8 Q T7 s! _0 y; F6 L9 H; I
floor$ |/ Q' H8 l; i/ O
(num num) 地板,向下取整。 Example double myval = floor(2.3); // Sets myvalto 2. ( P. M4 y' }# b! e
double myval = floor(3.8); // Sets myval to 3.
/ z. s: N9 x( w3 Ndouble myval = floor(-2.3); // Sets myval to -3. 6 b( G/ P' @: Z% Z
double myval = floor(-3.8); // Sets myval to -4. & t3 I( F4 H$ u& W
! w* q u5 @; F% \
round E2 }7 d; q* f0 ~7 m! g! l) T
(num value[, num precision]) 根据指定的小数位数进行四舍五入。 Example int mynum1 = round(3.6269);. c% Z. O1 u6 }0 h# T4 ?5 P3 o3 N
int mynum2 = round(3.6269,2);
* F& ~- J$ F7 \3 T, h& Q. r5 g# h% Y$ W% n8 g( f
mynum1 will be 4, and mynum2 will be 3.63. % g2 G0 @5 } S! e, g# D
2 q5 _- A3 z" F+ Q5 ]1 e* Q0 @( n
trunc
3 u7 Y' A: H; x' ~2 @# d7 n2 Z s3 D(num value) 去除小数部分取整。Truncation Example trunc(2.478), returns 2 a s, X" D6 p& b6 v9 U1 F, u/ y
' l- E4 P2 u9 d* Y; p$ D: z
trunc(2.95), returns 2
0 m6 d% }7 u$ ^3 P3 { frac
5 }& P( t! q6 r$ u/ T. r5 ~( ?0 O(num value) 取小数点之后的部分。 Example frac(3.124) returns 0.124
6 Q1 j7 @1 K2 z8 I8 h8 p8 ^frac(-16.12) returns -0.12
; w) J( u+ @/ C- }: s; g+ lfrac(12) returns 0.0 ( B. d1 T5 ^2 J
5 s7 ]/ r4 [( g sign, X, U( A- d' }$ U. D1 @* L1 ` a9 V
(num value) 决断正负零,正数返回1,负数返回-1,0返回0。 Example sign(-1)
# R+ C% l6 m6 _& B7 s' W
! e* d6 Z/ J! a0 [ fabs. u2 L: [! h& `7 [. L
(num value) 绝对值。 Example if(fabs(x1 - x2) > 5)
( K& F8 W9 T; l( T! U4 o8 b& Y+ @ m l' w$ f( @& H
factorial8 z5 U/ ]# `- j9 I: T" X' T. ?
(num value) 阶乘。 Example factorial(5) + ]. z* X. a7 f( b4 r. b+ J" c
5 T" l6 R$ S. s, a$ M$ I
This calculates the factorial of 5, which is 1*2*3*4*5 = 120
( j* v& j, A' g& x' z2 Z/ w6 w. X! L3 ~& |& s
fmod J+ c- r/ A. U J2 [, u
(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." ?, t2 W1 Q0 e8 C& u, e" ]
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
) z I( K8 E% \9 E9 H3 _3 |3 }" h! i7 Y
if(fmod(current.stats.output,10) == 0). p$ }- E b' R* q: n
0 x$ \9 a) D. X t) X% l
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.
" ]- }2 m3 T6 Y" _# e
+ c5 s) @+ D3 Z9 i) G pow
" x. W' a1 g: k, u% b- L" n(num num1, numnum2) 乘方。 Example double myval = pow(2,3); Sets myval to 8. P- C- {! A" Z$ q+ i
5 K+ N$ ] V* \
sqr
) G5 L4 S$ D# R" G2 M$ q(num value) 平方Square of value. Example sqr(2) ; a* c+ L" C( g: o2 \
. N3 [- J# c- d1 I' _; m. U sqrt
7 g# A X3 Q8 j# x' Z! r8 z(num value) 平方根Square root of value Example sqrt(10) This expression will return 3.16 , `1 E' Y5 P( J" \) |8 S" X
}* X9 M4 b% m e- |9 R- D8 t% ?
9 { E; a9 ^6 v" l( p, j6 ^9 Y1 T( ]
比如,我们要计算托盘上有多少层货物。/ k" `; f/ e C" Q
默认情况下,pallet上面每层可以放置4个box。也就是说,1,2,3,4个box都算1层,5,6,7,8个box都算是2层。7 ~7 K8 A+ i# Y
此时可以用ceil函数向上取整,ceil(content(pallet)/4)即可得到正确的层数。
. b! _& r; k& C2 r
|