Formulation » 历史记录 » 版本 2
yangdefeng, 2023-08-17 16:21
| 1 | 1 | yangdefeng | h4. _*%{color:green}formulation%*_ |
|---|---|---|---|
| 2 | |||
| 3 | 四则运算计算 |
||
| 4 | |||
| 5 | 标签:命令定义|formulation>formulation |
||
| 6 | |||
| 7 | *格式* |
||
| 8 | |命令名 |参数1 |参数2 |参数3 | |
||
| 9 | |formulation |计算公式 |存入变量 |小数处理模式 | |
||
| 10 | |||
| 11 | 说明: |
||
| 12 | * 参数1: 计算公式 |
||
| 13 | / 代表除 |
||
| 14 | <notextile>* 代表乘</notextile> |
||
| 15 | + 代表加 |
||
| 16 | - 代表减 |
||
| 17 | % 为取余数 |
||
| 18 | () 优先计算括号 |
||
| 19 | |||
| 20 | * 参数2: 存入变量 |
||
| 21 | |||
| 22 | * 参数3: 小数处理模式 |
||
| 23 | 0或缺省,结果四舍五入 |
||
| 24 | 1,丢弃掉小数 |
||
| 25 | |||
| 26 | - |
||
| 27 | - |
||
| 28 | |||
| 29 | h4. *%{color:deepskyblue}特戒引擎脚本示例:%* |
||
| 30 | |||
| 31 | bq. [<notextile>@</notextile>main] |
||
| 32 | #if |
||
| 33 | #act |
||
| 34 | 2 | yangdefeng | *{color:green}formulation* 2/(100+20)*100+100 n$切割值 |
| 35 | [[print]] 切割值为<$str(n$切割值)> |
||
| 36 | <notextile></notextile> |
||
| 37 | *{color:green}formulation* (10+20%9)%5 n$测试 |
||
| 38 | [[print]] 6 <$str(n$测试)> |
||
| 39 | <notextile></notextile> |
||
| 40 | #if |
||
| 41 | #act |
||
| 42 | [[mov]] n$数字100 100 |
||
| 43 | [[mov]] g50 50 |
||
| 44 | [[mov]] i99 10 |
||
| 45 | [[mov]] n80 80 |
||
| 46 | [[mov]] u200 200 |
||
| 47 | [[mov]] p80 80 |
||
| 48 | [[mov]] m100 10 |
||
| 49 | *{color:green}formulation* <notextile>(<$str(n$数字100)>+<$str(g50)>)/((<$str(i99)>+<$str(n80)>)*<$str(u200)>*(<$str(p80)>-12))+<$str(m100)></notextile> n$结果是4 |
||
| 50 | [[print]] 4运算的结果是<$str(n$结果是4)> |
||
| 51 | *{color:green}formulation* 2/(100+20)*100+100 u249 |
||
| 52 | [[print]] 1运算的结果是<$str(u249)> |
||
| 53 | *{color:green}formulation* <$str(n80)>*<$str(u200)> n$结果是 |
||
| 54 | [[print]] 2变量相乘运算的结果是<$str(n$结果是)> |