I can't seem to figure out how to test a number to see if it's zero. Couldn't someone please tell me what I'm missing.
getMin = Number.class
getMax = Number.class
Test
Number value = mvFacet.getMin() > 0 ? mvFacet.getMin() : mvFacet.getMax();
System.out.println(value.toString());
To add to Jason's answer, if you're going to use num.doubleValue() then don't use == since it doesn't handle edge cases like when the double value is NaN or Infinity. Please use Double.compare(num.doubleValue(), 0.0);.
Number num;
...
if(num.intValue() == 0) {
// num is 0 so do something here
}
Other methods available on Number are:
byteValue()
doubleValue()
floatValue()
longValue()
shortValue()
Select whichever method makes the most sense for the values you are using.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With