September 25, 2009

Java BigDecimal is negative?

9  comments

To check if a BigDecimal in Java is negative use the signum() method like it’s shown in the following snippet:

    public static boolean isNegative(BigDecimal b)
    {
        b.signum() == -1;
    }

Tags

BigDecimal, Java, Snippets


You may also like

Leave a Reply

Your email address will not be published. Required fields are marked

Information about Data protection

This site uses Akismet to reduce spam. Learn how your comment data is processed.

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}