1

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.

mskfisher
3,4124 gold badges38 silver badges50 bronze badges
asked May 3, 2012 at 0:19

2 Answers 2

5

Have you tried < and >? These operators are used for that sort of thing...

answered May 3, 2012 at 0:20
Sign up to request clarification or add additional context in comments.

2 Comments

Yeah was just wondering if there was a built in function. I say someone talking and exampling a build in thing for DOUBLE's
Javadoc: docs.oracle.com/javase/7/docs/api/java/lang/Double.html The built-in function would be the <name>.compareTo(Double anotherDouble)
3

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

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.