本帖最后由 zorsite 于 2017-5-31 03:15 编辑 $ J; y: V% {0 c& H; c
} R: q2 k4 Z" wceil9 z7 m1 A' k( Y- Q) h
(num num) 天花板,向上取整。 Example double myval =ceil(2.3); // Sets myval to 3. ' ^% h* s. g) m5 B( k
double myval = ceil(3.8); // Sets myval to 4.
; o/ H: A( o, G; a9 j/ Jdouble myval = ceil(-2.3); // Sets myval to -2.
6 R! k* k* D# Y* @% K! ddouble myval = ceil(-3.8); // Sets myval to -3. " V) u: X7 O, d2 [5 R3 h y
% @2 U1 U* S. Y, g4 t( e floor- W& ~ @7 b' i" L( l
(num num) 地板,向下取整。 Example double myval = floor(2.3); // Sets myvalto 2.
3 z+ }0 X9 X# h& }: R G' Qdouble myval = floor(3.8); // Sets myval to 3.
& W* A: ?9 ?7 Y s" I/ udouble myval = floor(-2.3); // Sets myval to -3.
7 o4 b8 v+ C7 \2 O6 Q0 f$ N* ?; ?double myval = floor(-3.8); // Sets myval to -4.
3 { P. R' n1 m$ z) ^
: J' {* y [& B round1 m4 t$ W( b8 b' ~9 {
(num value[, num precision]) 根据指定的小数位数进行四舍五入。 Example int mynum1 = round(3.6269);7 C5 {/ M: M6 T0 L
int mynum2 = round(3.6269,2);5 z' h2 m9 R: F' E" r
+ ]; T( i. I6 V2 p# J! C2 G+ I
mynum1 will be 4, and mynum2 will be 3.63.
U" s* A M0 e C& s. U# _! O/ x
( T5 l% L0 a( ?; x! n trunc
- [ q* c; ^( q. A(num value) 去除小数部分取整。Truncation Example trunc(2.478), returns 28 W$ g! v) l6 {/ O) ^! q
8 e! o& {4 d' k" o
trunc(2.95), returns 2& {' ?! Q Y1 G8 t
frac
* w0 F3 v% n" ~. b: P8 H, q(num value) 取小数点之后的部分。 Example frac(3.124) returns 0.124. J5 J- @6 r% q- h8 b
frac(-16.12) returns -0.12
" @0 e# Z2 L0 `frac(12) returns 0.0 2 R9 ^2 F1 P. O2 l. x
5 V$ X2 Q& @: S& h4 o. v' M- t sign7 m* v4 S I7 x3 @; Y' p4 k
(num value) 决断正负零,正数返回1,负数返回-1,0返回0。 Example sign(-1)
: j" ~# n9 R9 O1 B, ~( A6 g0 |2 m* [' ^5 F |3 c! @! `. e
fabs2 \' n' J9 j0 y1 b5 |4 H
(num value) 绝对值。 Example if(fabs(x1 - x2) > 5) : S3 U7 N& d) W' P* V/ A
- W0 H* u1 I) R$ y factorial
9 Y8 l8 Q8 l$ P4 {, e8 t9 t. ~(num value) 阶乘。 Example factorial(5) ; [6 O2 I6 L- u. F7 ^2 A
3 J% ^6 n3 n6 A: O
This calculates the factorial of 5, which is 1*2*3*4*5 = 120
/ C: T& T0 o' c2 b2 {8 ]% R. f1 N! g7 `
fmod
7 K) J$ i1 B! G' K( o- d* e- \(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.% |; b' m: _* M* `0 R. H6 k4 }' 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
3 U1 l7 o$ D# I2 K6 G! H5 J: N% J6 U# c+ ^( L
if(fmod(current.stats.output,10) == 0): W4 z. G3 m* ^" c8 z; s, p
- m' w2 g( c: J6 c5 g8 |& DIf 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. 7 Q b8 {! x2 R5 x
& d2 j# l2 w! K. p$ d5 i" r pow4 C* X8 L/ W& x2 j- C3 h( b
(num num1, numnum2) 乘方。 Example double myval = pow(2,3); Sets myval to 8. * L/ D5 o' `$ j" l$ t& z
6 C3 R) i" Z9 p2 @& O4 p7 S
sqr/ q( N7 ~6 ?8 L0 s/ {
(num value) 平方Square of value. Example sqr(2) ! f! x& ^4 O( u e
# O, D' |- U# |0 q, s8 n sqrt
* b j3 L* I6 _(num value) 平方根Square root of value Example sqrt(10) This expression will return 3.16
6 F& {8 D/ H4 O" _" e
8 s k( T3 E) J% w% E# d" O5 e: E/ ]' Y9 H1 W4 U. J# @8 A
比如,我们要计算托盘上有多少层货物。
6 W+ S# s$ i& m8 `& u" T默认情况下,pallet上面每层可以放置4个box。也就是说,1,2,3,4个box都算1层,5,6,7,8个box都算是2层。" |. Z+ C. y5 p7 o6 ?3 P4 B
此时可以用ceil函数向上取整,ceil(content(pallet)/4)即可得到正确的层数。 3 G* } Z4 |1 E8 `0 ~9 |2 [, R* f
|