Page 2 of 2 FirstFirst 12
Results 21 to 29 of 29
  1. #21
    diskhub is offline Member
    Join Date
    May 2010
    Posts
    25
    Rep Power
    0

    Default

    i don't know... i assume i need a counter and if it's not 31, then increment it to 0 to fill it up
    for the 32 place, check it's positive or not... then use 1.

  2. #22
    diskhub is offline Member
    Join Date
    May 2010
    Posts
    25
    Rep Power
    0

    Default

    NUM is an int.
    i was thinking that it will check the places it has computed for the binary places... and then if it will fill the remaining with 0

    last bit(31th) i will check positive or neg.

  3. #23
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by diskhub View Post
    NUM is an int.
    i was thinking that it will check the places it has computed for the binary places... and then if it will fill the remaining with 0

    last bit(31th) i will check positive or neg.
    It will, and the most difficult part. Go through the API code first of all.

  4. #24
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,783
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by diskhub View Post
    so no guide?
    i thought of one... but might not be a prof way...

    that's why i wanted to see what u expert can do... nevermind, i guess u guys are also not used to this tricky question. :D
    No, we forgot all about it or we never learned how to use them ;-) btw don't use that ugly expression NUM-(NUM>>1<<1) use the much simpler expression NUM&1 instead if you really want to reinvent the wheel. Also btw if you want to chop off the rightmost bit of a number in a loop you end up with all the bits generated from right to left; better use a mask 0x80000000, use that and shift it to the right at every loop pass until your mask becomes zero.

    kind regards,

    Jos

  5. #25
    diskhub is offline Member
    Join Date
    May 2010
    Posts
    25
    Rep Power
    0

    Default

    yup, agree. NUM&1 is so much better.
    Thanks everyone.

  6. #26
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

  7. #27
    diskhub is offline Member
    Join Date
    May 2010
    Posts
    25
    Rep Power
    0

    Default

    thanks for your concern
    I read ur sample code and modified it
    and it works perfectly.

    cheers.

  8. #28
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    Welcome :)

    If you've solved the problem please mark the thread solved. I hope you know that how to do it.

  9. #29
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    One more thing I want to added.

    What you've done is really nice work. But it needs really hard work, really difficult stuff. That's why I guide you to look at how Suns' people handle this.

    At the same time the provide easy access to use them in easy way, no need to implement again and again. :)

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Replies: 4
    Last Post: 10-26-2009, 11:17 PM
  2. Convert binary into decimal
    By WarmRegards in forum New To Java
    Replies: 8
    Last Post: 10-18-2009, 03:32 PM
  3. convert binary to images
    By fiqueudrue in forum New To Java
    Replies: 3
    Last Post: 02-12-2009, 10:16 AM
  4. Using the bitwise operators
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-17-2008, 08:39 PM
  5. Use recursion to convert binary to...
    By coco in forum Advanced Java
    Replies: 1
    Last Post: 08-07-2007, 08:46 AM

Posting Permissions

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