如何检查给定的值是正整数还是负整数? [英] How to check the value given is a positive or negative integer?
本文介绍了如何检查给定的值是正整数还是负整数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我为变量分配了值10;
Lets say i have the value 10 assigned to a variable;
var values = 10;
如果值是正数,我想运行特定功能
and i want to run a specific function if the value is a positive
if(values = +integer){
//do something with positive
} else {
//do something with negative values
}
这将如何实现?
推荐答案
if (values > 0) {
// Do Something
}
这篇关于如何检查给定的值是正整数还是负整数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文