开发者

If-Statement checking vor a value between two others

Is there a kind of "between" check I can use in an if-s开发者_如何学运维tatement that verifies whether a given float value is between two others?

Can I write something like

if (floatConstA <= checkFloatValue < foatConstB) {

or must I do this using AND/OR constructs?


You have to do it with &&:

if (floatConstA <= checkFloatValue && checkFloatValue < foatConstB) {


You have to write it like 2 separate conditions, eg.

if((floatConstA <= checkFloatValue) && (checkFloatValue < floatConstB)) {
...
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜