本帖最后由 zorsite 于 2017-5-31 03:15 编辑 , ~) |1 d* Q0 w1 c- r5 s+ e
6 S$ C5 |/ l& n; y) Q8 yceil
8 g) S! B& X' t1 ]% J$ M(num num) 天花板,向上取整。 Example double myval =ceil(2.3); // Sets myval to 3. ! i& R& N, \) p) c' ^5 U8 r. b4 [$ M/ h
double myval = ceil(3.8); // Sets myval to 4. ; j( s2 y* F& G: t$ @$ e: N
double myval = ceil(-2.3); // Sets myval to -2. 1 ]' w& M, f7 T( I6 e; r$ b( u9 u
double myval = ceil(-3.8); // Sets myval to -3.
7 D: `9 I3 z( K3 Z1 |) ~5 L- |
+ d; N: j8 ^0 \ floor
( W; D. [5 W/ C. D, d9 ]$ M9 x) E(num num) 地板,向下取整。 Example double myval = floor(2.3); // Sets myvalto 2.
0 w& q3 i+ C; v0 O4 Adouble myval = floor(3.8); // Sets myval to 3.
$ |7 R% \& N! Y1 J' Qdouble myval = floor(-2.3); // Sets myval to -3.
: ^- b# X1 ~+ fdouble myval = floor(-3.8); // Sets myval to -4.
: y E( @9 {* m. z* J
& G+ Y" V* H1 J5 c- h( \ round
1 o a1 E& U8 O(num value[, num precision]) 根据指定的小数位数进行四舍五入。 Example int mynum1 = round(3.6269);
% G+ }; h. W8 g# n! F2 \9 }int mynum2 = round(3.6269,2); O* t- V9 t6 g+ E
( E1 ]+ A% C! @mynum1 will be 4, and mynum2 will be 3.63. ' ^9 V+ j5 A6 M, T7 `
- Z6 T3 a1 \ e$ G$ u
trunc, z% T$ J. Z2 V/ y) ^
(num value) 去除小数部分取整。Truncation Example trunc(2.478), returns 2
" z4 ^' h9 P7 I# I8 }
6 i) ]* i2 y& Z+ N! F4 Ttrunc(2.95), returns 2
& @1 K# Q+ V9 B( z$ v7 x frac
& S3 i& n8 |) m- `(num value) 取小数点之后的部分。 Example frac(3.124) returns 0.124
$ K2 m2 k e/ U- R0 J* b$ sfrac(-16.12) returns -0.12
: x+ R% H9 o6 \+ @$ f" }: E' I# ufrac(12) returns 0.0
2 n% U% N4 h& l1 J, ~. f! r- t) K2 C A( t2 R4 E
sign
, j } Z5 ?2 h4 J* W' B(num value) 决断正负零,正数返回1,负数返回-1,0返回0。 Example sign(-1) - P, }, r4 T, u7 J$ |1 _( A5 q
4 m; J+ E0 g. B# } a c fabs$ I( Q% [; c i* P# ?
(num value) 绝对值。 Example if(fabs(x1 - x2) > 5) / {7 R/ O- ^! G' E+ x4 O2 z
* J& _$ v. z) u3 H( i* m6 }
factorial/ K e$ x) y2 H& c' }5 X
(num value) 阶乘。 Example factorial(5) & f8 s+ n( F% T% E5 K- H
9 _% a4 w: @" X; lThis calculates the factorial of 5, which is 1*2*3*4*5 = 120
* m9 e* P' {+ M5 `
7 G$ W0 D- R% L$ S a8 J, V fmod
3 V* h0 u) n8 b% G* a; 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.( c- x8 L% [3 G) K+ ~/ 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
- @0 V" l# W4 E/ ]
9 m6 [$ b- l+ ]* J" K1 v, e* Pif(fmod(current.stats.output,10) == 0)- D' k9 B/ R3 ^/ |
$ i, Y$ o$ F$ q8 N$ r
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 Y( ^- y2 K" G0 @" \+ {
# d0 z2 S4 D/ f! P0 v& b pow
: b3 |0 @; _2 i- o. z- }; r0 C(num num1, numnum2) 乘方。 Example double myval = pow(2,3); Sets myval to 8.
( |& M3 x" J/ a7 a# L, W' a# e" G, @( m; g8 u8 k
sqr
3 h, v- g3 Q" q9 N(num value) 平方Square of value. Example sqr(2) . p" s Y6 k8 B0 \1 e: N3 I7 T
- P0 e4 Y, p9 `) [ sqrt: j; _' }# u9 U5 M" H+ |4 |
(num value) 平方根Square root of value Example sqrt(10) This expression will return 3.16 $ a4 S# s' U( a+ ^' M
3 }# u4 x2 k) j& b, n
' ^4 D; ~! [ I; j% Q/ _比如,我们要计算托盘上有多少层货物。7 y; R( Q7 h3 a% E5 L
默认情况下,pallet上面每层可以放置4个box。也就是说,1,2,3,4个box都算1层,5,6,7,8个box都算是2层。
. ?5 w. V/ b; ? h1 Y9 y此时可以用ceil函数向上取整,ceil(content(pallet)/4)即可得到正确的层数。 ( b/ C- d8 ?+ w" W
|