views:

40

answers:

2

Is there a kind of "between" check I can use in an if-statement 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?

+2  A: 

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

if((floatConstA <= checkFloatValue) && (checkFloatValue < floatConstB)) {
...
}
Claus Broch
+2  A: 

You have to do it with &&:

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