if(val=='0' || val=='1' || val == '2' || val == '3' || val == '4' || val == '5' || val == '6')
时间: 2024-08-15 15:05:35 浏览: 112
在C/C++编程语言中,`if(val=='0' || val=='1' || val=='2' || val=='3' || val=='4' || val=='5' || val=='6')`是一个条件判断语句,用于检查变量`val`的值是否等于整数0到6之间的任意一个数字(包括0和6)。这个表达式的逻辑运算基于布尔算术。
**解释语法:**
- **`==`**: 表示相等比较操作。如果左侧的操作数等于右侧的操作数,则返回true(即非零值),否则返回false(即0)。
- **`||`**: 是“或”运算符。如果两侧任一操作的结果为true,则整个表达式的结果也为true。只有当两边都为false时,整个表达式才为false。
因此,上述的条件语句会在满足以下情况之一时执行其后的代码块:
- `val` 等于 `'0'`
- `val` 等于 `'1'`
- `val` 等于 `'2'`
- `val` 等于 `'3'`
- `val` 等于 `'4'`
- `val` 等于 `'5'`
- `val` 等于 `'6'`
请注意,这里的字符比较实际上是基于ASCII码表的位置进行的,每个数字字符(如'0', '1', '2', ...,'9')都有对应的ASCII值。由于这里只比较了'0'-'6',所以这种做法是有效的。
---
相关问题
帮我调整以下代码的排版: <script> jQuery(document).ready(function(){ var qjlxvalue = WfForm.getFieldValue(WfForm.convertFieldNameToId("qjlx")); console.info(qjlxvalue); WfForm.registerCheckEvent(WfForm.OPER_SUBMIT, function(callback){ var qjksrq_value = WfForm.getFieldValue(WfForm.convertFieldNameToId("qjksrq")); var qjjsrq_value = WfForm.getFieldValue(WfForm.convertFieldNameToId("qjjsrq")); var qjksrq_valuesub= qjksrq_value.substring(0,4); var qjjsrq_valuesub= qjjsrq_value.substring(0,4); var qjlx_val = WfForm.getFieldValue(WfForm.convertFieldNameToId("qjlx")); var qjsc_val = WfForm.getFieldValue(WfForm.convertFieldNameToId("qjsc")); qjsc_val = parseFloat(qjsc_val); if(qjlx_val =='2' || qjlx_val=='6' || qjlx_val =='7'|| qjlx_val=='8' || qjlx_val =='9'|| qjlx_val=='10' || qjlx_val =='11'|| qjlx_val=='13' || qjlx_val =='14'|| qjlx_val=='15' || qjlx_val =='35'|| qjlx_val=='34' || qjlx_val =='20'|| qjlx_val=='27' || qjlx_val =='21'|| qjlx_val=='22' || qjlx_val =='23'|| qjlx_val=='24' || qjlx_val =='26' || qjlx_val =='28'){ if(qjsc_val<3.5){ WfForm.showMessage("请假时长必须大于3个半小时,请重新提交", 2, 10); }else{ callback(); //继续提交需调用callback,不调用代表阻断 } } }); var fieldMark = WfForm.convertFieldNameToId("qnqjtsmd"); WfForm.bindFieldChangeEvent(fieldMark, function(obj,id,value){ var fieldMarkqnqjtsmd =WfForm.getFieldValue(WfForm.convertFieldNameToId("qnqjtsmd")); //获取全年请假天数埋点 if(fieldMarkqnqjtsmd>=12){ WfForm.changeFieldValue(WfForm.convertFieldNameToId("qnqjts"), {value: "0"}); }else{ WfForm.changeFieldValue(WfForm.convertFieldNameToId("qnqjts"), {value: "1"}); } }); var yjbmValue = getFieldValue('yjbm'); if (yjbmValue === '71') { var qjscValue = parseInt(getFieldValue('qjsc')); var newValue = qjscValue / 8; setFieldValue('yxrydqjts', newValue); } </script>
<script>
jQuery(document).ready(function() {
var qjlxvalue = WfForm.getFieldValue(WfForm.convertFieldNameToId("qjlx"));
console.info(qjlxvalue);
WfForm.registerCheckEvent(WfForm.OPER_SUBMIT, function(callback) {
var qjksrq_value = WfForm.getFieldValue(WfForm.convertFieldNameToId("qjksrq"));
var qjjsrq_value = WfForm.getFieldValue(WfForm.convertFieldNameToId("qjjsrq"));
var qjksrq_valuesub = qjksrq_value.substring(0, 4);
var qjjsrq_valuesub = qjjsrq_value.substring(0, 4);
var qjlx_val = WfForm.getFieldValue(WfForm.convertFieldNameToId("qjlx"));
var qjsc_val = WfForm.getFieldValue(WfForm.convertFieldNameToId("qjsc"));
qjsc_val = parseFloat(qjsc_val);
if (qjlx_val == '2' || qjlx_val == '6' || qjlx_val == '7' || qjlx_val == '8' || qjlx_val == '9' || qjlx_val == '10' || qjlx_val == '11' || qjlx_val == '13' || qjlx_val == '14' || qjlx_val == '15' || qjlx_val == '35' || qjlx_val == '34' || qjlx_val == '20' || qjlx_val == '27' || qjlx_val == '21' || qjlx_val == '22' || qjlx_val == '23' || qjlx_val == '24' || qjlx_val == '26' || qjlx_val == '28') {
if (qjsc_val < 3.5) {
WfForm.showMessage("请假时长必须大于3个半小时,请重新提交", 2, 10);
} else {
callback(); //继续提交需调用callback,不调用代表阻断
}
}
});
var fieldMark = WfForm.convertFieldNameToId("qnqjtsmd");
WfForm.bindFieldChangeEvent(fieldMark, function(obj, id, value) {
var fieldMarkqnqjtsmd = WfForm.getFieldValue(WfForm.convertFieldNameToId("qnqjtsmd")); //获取全年请假天数埋点
if (fieldMarkqnqjtsmd >= 12) {
WfForm.changeFieldValue(WfForm.convertFieldNameToId("qnqjts"), { value: "0" });
} else {
WfForm.changeFieldValue(WfForm.convertFieldNameToId("qnqjts"), { value: "1" });
}
});
var yjbmValue = getFieldValue('yjbm');
if (yjbmValue === '71') {
var qjscValue = parseInt(getFieldValue('qjsc'));
var newValue = qjscValue / 8;
setFieldValue('yxrydqjts', newValue);
}
});
</script>
const blurGoodsDecimal = (val, i) => { let data = OrderDetailsParam.value.inquiryGoodsParams; data[i][val] = Number(data[i][val]); if (val == "length" || val == "wide" || val == "high") { oneVolume(data, i); getTotalVolume(data, i); } if (val == "singleBoxVolume" || val == "ctns" || val == "singleBoxWeight") { getTotalVolume(data, i); getTotalWeight(data, i); } getTotalRatio(data, i); getBillingTotal(data, i); };改成使用Big.js
const blurGoodsDecimal = (val, i) => {
let data = OrderDetailsParam.value.inquiryGoodsParams;
data[i][val] = new Big(data[i][val]);
if (val === "length" || val === "wide" || val === "high") {
oneVolume(data, i);
getTotalVolume(data, i);
}
if (
val === "singleBoxVolume" ||
val === "ctns" ||
val === "singleBoxWeight"
) {
getTotalVolume(data, i);
getTotalWeight(data, i);
}
getTotalRatio(data, i);
getBillingTotal(data, i);
};
以上代码已经使用了 Big.js 进行了修改,以确保精确计算。
阅读全文