Study guides

☆☆

Q: What is the English representation of the binary string 01100001?

Write your answer...

Submit

Still have questions?

Related questions

Assume read from Console string inputString = Console.ReadLine(); int inputDecimalValue = int.Parse(inputString); //Now convert the input decimal value to a binary representation, as a string string binaryString = Convert.ToString(inputDecimalValue, 2); // 2 means binary base

A byte

import java.util.Scanner; public class NumberSystem { public void displayConversion() { Scanner input = new Scanner(System.in); System.out.printf("%-20s%-20s%-20s%-20s\n", "Decimal", "Binary", "Octal", "Hexadecimal"); for ( int i = 1; i <= 256; i++ ) { String binary = Integer.toBinaryString(i); String octal = Integer.toOctalString(i); String hexadecimal = Integer.toHexString(i); System.out.format("%-20d%-20s%-20s%-20s\n", i, binary, octal, hexadecimal); } } // returns a string representation of the decimal number in binary public String toBinaryString( int dec ) { String binary = " "; while (dec >= 1 ) { int value = dec % 2; binary = value + binary; dec /= 2; } return binary; } //returns a string representation of the number in octal public String toOctalString( int dec ) { String octal = " "; while ( dec >= 1 ) { int value = dec % 8; octal = value + octal; dec /= 8; } return octal; } public String toHexString( int dec ) { String hexadecimal = " "; while ( dec >= 1 ) { int value = dec % 16; switch (value) { case 10: hexadecimal = "A" + hexadecimal; break; case 11: hexadecimal = "B" + hexadecimal; break; case 12: hexadecimal = "C" + hexadecimal; break; case 13: hexadecimal = "D" + hexadecimal; break; case 14: hexadecimal = "E" + hexadecimal; break; case 15: hexadecimal = "F" + hexadecimal; break; default: hexadecimal = value + hexadecimal; break; } dec /= 16; } return hexadecimal; } public static void main( String args[]) { NumberSystem apps = new NumberSystem(); apps.displayConversion(); } }

import java.util.Scanner; public class NumberSystem { public void displayConversion() { Scanner input = new Scanner(System.in); System.out.printf("%-20s%-20s%-20s%-20s\n", "Decimal", "Binary", "Octal", "Hexadecimal"); for ( int i = 1; i <= 256; i++ ) { String binary = Integer.toBinaryString(i); String octal = Integer.toOctalString(i); String hexadecimal = Integer.toHexString(i); System.out.format("%-20d%-20s%-20s%-20s\n", i, binary, octal, hexadecimal); } } // returns a string representation of the decimal number in binary public String toBinaryString( int dec ) { String binary = " "; while (dec >= 1 ) { int value = dec % 2; binary = value + binary; dec /= 2; } return binary; } //returns a string representation of the number in octal public String toOctalString( int dec ) { String octal = " "; while ( dec >= 1 ) { int value = dec % 8; octal = value + octal; dec /= 8; } return octal; } public String toHexString( int dec ) { String hexadecimal = " "; while ( dec >= 1 ) { int value = dec % 16; switch (value) { case 10: hexadecimal = "A" + hexadecimal; break; case 11: hexadecimal = "B" + hexadecimal; break; case 12: hexadecimal = "C" + hexadecimal; break; case 13: hexadecimal = "D" + hexadecimal; break; case 14: hexadecimal = "E" + hexadecimal; break; case 15: hexadecimal = "F" + hexadecimal; break; default: hexadecimal = value + hexadecimal; break; } dec /= 16; } return hexadecimal; } public static void main( String args[]) { NumberSystem apps = new NumberSystem(); apps.displayConversion(); } }

Number, string, binary string.

#include <iostream> #include <string> // Converts value to any base (2 to 16) and returns the string representation std::string convBase(unsigned long val, long base) { std::string digits = "0123456789abcdef"; std::string result; if((base < 2) (base > 16)) { result = "Error: base out of range."; } else { do { result = digits[val % base] + result; val /= base; } while(val); } return( result ); } // Converts a binary string to its decimal equivalent int bin2dec(std::string binary) { int decimal=0, bit=1; for( int i=binary.size()-1; i>=0; --i ) { if( binary.at(i)=='1') decimal += bit; bit <<= 1; } return( decimal ); } int main() { for( int num=0; num<256; ++num ) { std::string binary = convBase( num, 2 ); while( !binary.size() binary.size()%8 ) binary.insert( 0, "0" ); int decimal = bin2dec( binary ); std::cout << binary << " = " << decimal << std::endl; } return(0); }

Eight binary digits are called a byte.Four binary digits are a nibble.

Looks like Binary, which is basically your computer using 1's and 0's to represent letters and numbers. The first string you have there 1011010 is the binary representation for the letter Z... the second one, looks like it has an extra character in there so it could be any number of letters.

Each 4-digit string of binary digits is equivalent to 1 single hexadecimal digit.

Not quite sure what you mean by "holes"; "binary data" consists of a string of ones and zeros.

The first step is to use a function to convert the number (integer, floating point or otherwise) into a string. The next step is to convert each character within that string to its binary equivalent. Converting an unsigned char to binary will require the use of bitwise operators, specifically &, << and >>. There are plenty of code snippets on the Web that show you how to accomplish this task, however it might be worth your while to work it out on paper first and then write the code. The best recommendation at this point is to explore bitwise operators in C and understand how binary math works. You'll likely find many uses for this knowledge in the future.

sOutput has the value "12.3" (the string representation of 12.3f).

People also asked