Results 1 to 2 of 2
  1. #1
    perito is offline Member
    Join Date
    Feb 2008
    Posts
    9
    Rep Power
    0

    Default BigInteger remainder results in zero

    Java Code:
    BigInteger nbr = BigInteger.valueOf(4);
    BigInteger i = BigInteger.valueOf(2);
    nbr.remainder(i) == BigInteger.ZERO
    this returns false, it should return true, the remainder is zero...
    why is it returning false?
    although if u check each one alone, they are ZEROS and they are equal!!!
    why is it returning false?

  2. #2
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    8

    Default

    Better to use the equals method when comparing objects.
    Java Code:
    System.out.printf("four %% two equals BigInteger.ZERO = %b%n",
                       four.remainder(two).equals(BigInteger.ZERO));

Similar Threads

  1. How to convert a string into a BigInteger
    By valery in forum New To Java
    Replies: 4
    Last Post: 09-13-2011, 01:32 PM
  2. date and calender not getting the right results
    By valoyivd in forum New To Java
    Replies: 4
    Last Post: 04-14-2008, 11:51 AM
  3. results to code disappear too fast for DOS window
    By dubdubdub in forum New To Java
    Replies: 3
    Last Post: 12-29-2007, 05:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •