本帖最后由 zorsite 于 2017-5-31 03:15 编辑
5 Q2 m# Z5 |( | P; X' n9 v# i
, j$ V2 {. k" d0 f+ i( @3 w" cceil" ~- ~1 H) e/ X% Q1 x9 s; u
(num num) 天花板,向上取整。 Example double myval =ceil(2.3); // Sets myval to 3.
9 q' ]/ H' X. K3 \" W$ ~; A) Tdouble myval = ceil(3.8); // Sets myval to 4.
$ b( w( ^) z" m5 X; r6 bdouble myval = ceil(-2.3); // Sets myval to -2.
8 z& @, E) u/ h# S+ |! }5 Mdouble myval = ceil(-3.8); // Sets myval to -3. . U E+ @$ f! @3 m* g- m. z: G
6 b( m, V- @4 B5 `) Y3 ]* M/ G w
floor
. \' y4 } c, A' G% O' j3 Z, ^(num num) 地板,向下取整。 Example double myval = floor(2.3); // Sets myvalto 2. # d+ P H3 a/ A* V
double myval = floor(3.8); // Sets myval to 3. 0 L, f3 M- R# q* j% A
double myval = floor(-2.3); // Sets myval to -3. , H. |) A4 I4 \% P7 d/ R
double myval = floor(-3.8); // Sets myval to -4. : l* C& K' v2 P: s+ U
# @( p% w" N+ V7 D
round: w# U; z$ c% j
(num value[, num precision]) 根据指定的小数位数进行四舍五入。 Example int mynum1 = round(3.6269);
( D" [7 y; y+ U+ Z5 B5 \int mynum2 = round(3.6269,2);
- @) J8 O+ B8 a y" u
, R9 a8 Q! s7 b. J/ ~/ cmynum1 will be 4, and mynum2 will be 3.63.
) S9 N! D3 {6 M2 k
4 U. b6 u( n) P3 @% e trunc. w8 o; A0 [7 z& z4 t& K
(num value) 去除小数部分取整。Truncation Example trunc(2.478), returns 28 f0 B7 g% m0 x7 o
2 P" R! O4 c! U: v( ktrunc(2.95), returns 2
2 ~# x7 I, s: J8 w# j4 { frac+ p" i# `+ v* [9 F4 R1 [# ]+ q9 j
(num value) 取小数点之后的部分。 Example frac(3.124) returns 0.124
* M/ e& ^0 |/ K8 D& tfrac(-16.12) returns -0.12
' j! E- D7 J `4 k# p! tfrac(12) returns 0.0
% D! m% ]# O1 `/ d& P D: E( m7 {- a8 f% M
sign/ O7 x& q4 Y6 L \* Y
(num value) 决断正负零,正数返回1,负数返回-1,0返回0。 Example sign(-1)
; Y5 b1 C* p2 M2 L( W/ D
$ x' \/ M- z/ u: W fabs
9 P. q/ E0 ^! V t(num value) 绝对值。 Example if(fabs(x1 - x2) > 5) p3 F0 ?3 c% _( x; W
! ]7 w- B4 r5 H+ w factorial
& ^/ ~! ?2 [$ k8 p9 u3 J(num value) 阶乘。 Example factorial(5) ! d2 M3 k1 S5 r$ w7 m* D r+ F% M
6 p8 K9 P# o( z. Z# d# W: x4 G) `; i5 gThis calculates the factorial of 5, which is 1*2*3*4*5 = 120
: x, W8 v$ l/ h+ Z$ C
! n4 Y( e7 u6 |" x1 q fmod+ n% h3 ]& p7 J" v% z
(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.- i0 D6 B2 v! @1 A7 \; T
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
9 D& h$ M7 w* b
1 g& Q$ L- \- D6 T3 A! I7 `if(fmod(current.stats.output,10) == 0)" [5 t* {; H9 ~. l7 F
' {3 S6 H" f9 v* @$ L. H
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.
$ q) [- r/ m7 D; {1 T0 }2 \3 [& p6 f
$ s% a+ s6 n8 Y# M7 G pow
) Y* U% `: Y* l& x; v& k* x* ^(num num1, numnum2) 乘方。 Example double myval = pow(2,3); Sets myval to 8. 4 [" L' _" u" e" p2 C
& r; w" V! p2 o4 s
sqr" y% z/ H/ B* d/ P8 C
(num value) 平方Square of value. Example sqr(2) / }( P3 D0 Y$ m: ^% s# f
7 J$ S) s( B0 X2 r# ?* {, v sqrt1 N9 i% R4 o3 M4 @: W' [
(num value) 平方根Square root of value Example sqrt(10) This expression will return 3.16 2 A4 z1 B4 j) _' t
! K4 M. O+ z4 U$ e! ?+ J
1 ]8 z# L$ ?7 u4 F7 ~8 I: f) X比如,我们要计算托盘上有多少层货物。) |8 b8 o$ o& S7 h6 q1 i4 c1 [6 m2 B
默认情况下,pallet上面每层可以放置4个box。也就是说,1,2,3,4个box都算1层,5,6,7,8个box都算是2层。8 S3 `+ D- u/ ^" B
此时可以用ceil函数向上取整,ceil(content(pallet)/4)即可得到正确的层数。
3 q& I. ]* {+ I+ i1 v$ C
|