Results 1 to 5 of 5
  1. #1
    mr2insane is offline Member
    Join Date
    Jun 2011
    Posts
    6
    Rep Power
    0

    Default Need some help!!!

    Thanks!
    Last edited by mr2insane; 06-04-2011 at 10:38 PM.

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,784
    Rep Power
    7

    Default

    What do you mean by binary number? eg: 10111011 or something else.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,193
    Rep Power
    19

    Default

    And if Junky's guess is correct, then you should be reading that as a String and parsing the input.

    Recommended reading: How to ask questions the smart way

    db

  4. #4
    mr2insane is offline Member
    Join Date
    Jun 2011
    Posts
    6
    Rep Power
    0

    Default

    junky is correct.

  5. #5
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,784
    Rep Power
    7

    Default

    In that case what Daryl posted is correct. You need to read teh input as a String. then you have 2 options to validate the input.

    1. Iterate over the String and check each character is a 1 or 0.

    2. Parse the String into an int inside a catch statement. If an exception is thrown then the input is not binary.

Posting Permissions

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