In the following piece of code i am trying to enter a 8 digit binary number then manipulate each digit seperatly.

import java.util.Scanner;
public class binCoverstion2{

   private static Scanner kbd = new Scanner(System.in);

   public static void main (String[] args){
      int bit0, bit1, bit2, bit3, bit4, bit5, bit6, bit7, decNumber;
      System.out.println("Enter a 8 digit binary number then hit enter.");
      String binaryNum = kbd.nextLine();
      bit0 = binaryNum.charAt(0);
      System.out.println(bit0);

The output of bit0 is just to see what the value was set too. the input i gave it was 10011001, but bit0 was set to 49. Why?

Java chars are really numeric values that represent Unicode (ASCII) characters, and as it happens the ASCII value for the character '1' is decimal 49 (see http://web.cs.mun.ca/~michael/c/ascii-table.html).
Your bit0 variable is an int, so Java displays it as a numeric value, not the character that it represents. If you declare bit0 as a char it will print more like you expect.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.