This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes Test for negative long? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Test for negative long?" Watch "Test for negative long?" New topic

Test for negative long?

myron schabe

Joined: Aug 21, 2002
Posts: 19
How can I test if a long is a negative rather than positive value?
Rodney Woodruff
Ranch Hand

Joined: Dec 04, 2001
Posts: 80
Check to see if the long is less than zero.
long myLong = -5L;
System.out.println(myLong < 0);
Prints "true" if negative.
Prints "false" if positive.

Hope This Helps
It is sorta covered in the JavaRanch Style Guide.
subject: Test for negative long?
Similar Threads
WA #1.....word association
negative marking
Shift operators
JUnit Testing