Results 1 to 2 of 2
  1. #1
    NoobieCode is offline Senior Member
    Join Date
    Mar 2013
    Rep Power

    Default confused on bits

    /* Initialize two static constants that will store
    * the maximum and minimum values possible using
    * a 32-bit signed integer.
    * In your assignment, use the << operator to compute the correct value.
    * Don't just assign the numeric literals (i.e. 2147483647 and -2147483648)
    final static int MAX = ??? ;
    final static int MIN = ???;

    I dont know what to do.

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Voorschoten, the Netherlands
    Blog Entries
    Rep Power

    Default Re: confused on bits

    Have a look at this: the maximum value has all its bits set except for the highest bit (the sign bit); so:

    Java Code:
    int max= (~0)>>>1;
    The minimum value only has its sign bit set, so:

    Java Code:
    int min= ~max;
    kind regards,

    Build a wall around Donald Trump; I'll pay for it.

Similar Threads

  1. How to restrict my binary output to 8 bits or 4 bits ?
    By Jack_Tauson_Sr in forum New To Java
    Replies: 16
    Last Post: 04-03-2013, 04:59 PM
  2. hiding bits in image
    By stegano in forum New To Java
    Replies: 1
    Last Post: 04-07-2011, 03:46 PM
  3. Help with random bits array
    By AnimeKitty in forum New To Java
    Replies: 11
    Last Post: 07-30-2010, 04:37 AM
  4. 48 bits JPEG 2000
    By user_java in forum Java 2D
    Replies: 0
    Last Post: 03-02-2010, 05:19 AM
  5. extracting bits from big numbers
    By ankitmcgill in forum New To Java
    Replies: 6
    Last Post: 05-05-2009, 04:36 AM

Tags for this Thread

Posting Permissions

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