I'm working with Android gestures and the onFling method. There are two float variables get passed velocityX and velocityY. Theses can either be 0.0, positive or negative. Obviously the 0.0 is easy to detect but how to I detect whether it's a positive or negative float.
I found some code for int and double but nothing relating to float specifically.
2 Answers 2
Have you tried < and >? These operators are used for that sort of thing...
answered May 3, 2012 at 0:20
apnorton
2,4501 gold badge21 silver badges34 bronze badges
Sign up to request clarification or add additional context in comments.
2 Comments
Flatlyn
Yeah was just wondering if there was a built in function. I say someone talking and exampling a build in thing for DOUBLE's
apnorton
Javadoc: docs.oracle.com/javase/7/docs/api/java/lang/Double.html The built-in function would be the <name>.compareTo(Double anotherDouble)
Just compare with 0.0. like this:
var x = 0.01;
var y = -0.01;
if (x > 0.0) { /* positive */ }
if (y < 0.0) { /* negative */ }
answered May 3, 2012 at 0:22
clee
11.2k6 gold badges38 silver badges29 bronze badges
Comments
Explore related questions
See similar questions with these tags.
lang-java