Premium Essay

Binary to Decimal

In:

Submitted By root08
Words 486
Pages 2
BINDEC import java.util.Scanner; public class Binary_Decimal { Scanner scan; int num; void getVal() { System.out.println("Binary to Decimal"); scan = new Scanner(System.in); System.out.println("\nEnter the number :"); num = Integer.parseInt(scan.nextLine(), 2); } void convert() { String decimal = Integer.toString(num); System.out.println("Decimal Value is : " + decimal); } } class MainClass { public static void main(String args[]) { Binary_Decimal obj = new Binary_Decimal(); obj.getVal(); obj.convert(); } }

-------------------------------------------

import java.util.Scanner; public class Binary_Octal { Scanner scan; int num; void getVal() { System.out.println("Binary to Octal"); scan = new Scanner(System.in); System.out.println("\nEnter the number :"); num = Integer.parseInt(scan.nextLine(), 2); } void convert() { String octal = Integer.toOctalString(num); System.out.println("Octal Value is : " + octal); }
}

class MainClass { public static void main(String args[]) { Binary_Octal obj = new Binary_Octal(); obj.getVal(); obj.convert(); }
}

-------------------

public class Binary_Hexa { Scanner scan; int num; void getVal() {

Similar Documents

Premium Essay

Decimal-Binary-Hexadecimal Conversion Chart

...Decimal-Binary-Hexadecimal Conversion Chart This chart shows all of the combinations of decimal, binary and hexadecimal from 0 to 25 5 decimal. When m aking a change in a C V this chart will show the conversion for different nu mb ering system s. Som e deco ders sp lit the C V in to tw o pa rts. W hen y ou mo dify a CV you need to w rite back all 8 bits. T his cha rt will help deter min e the co rrect bit va lue a C V. Decimal Binary Hex Decimal Binary Hex Decimal Binary Hex Decimal Binary Hex Bit N o.> 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 76543210 00000000 00000001 00000010 00000011 00000100 00000101 00000110 00000111 00001000 00001001 00001010 00001011 00001100 00001101 00001110 00001111 00010000 00010001 00010010 00010011 00010100 00010101 00010110 00010111 00011000 00011001 00011010 00011011 00011100 00011101 00011110 00011111 00100000 00100001 00100010 00100011 00100100 00100101 00100110 00100111 00101000 00101001 00101010 00101011 00101100 00101101 00101110 00101111 00110000 00110001 00110010 00110011 00110100 00110101 00110110 00110111 00111000 00111001 00111010 00111011 00111100 00111101 00111110 00111111 0 1 2 3 4 5 6 7 8 9 A B C D E F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F 64 65 66 67 68 69 70 71 72 73 74 75 76 77...

Words: 1079 - Pages: 5

Free Essay

Conversions Binary, Decimal

...1. Decimal to binary: 47.375= ( 101101.011 )2 2. Binary to decimal (unsigned): 1011.0102= ( 11.25 ) 3. Base 6 to base 5 2016= ( 243 )5 4. Base 3 to base 7 1023= ( 14 )7 5. Octal to binary 6278= ( 110 010 111 )2 6. Hex to binary OXA3E9= ( 1010 0011 1110 1001 )2 7. Octal to hex 7268=0x( 1D6 ) 8. Base 9 to base 3 8479= ( 22 11 21 )3 9. Base 6 to base 3 1356= ( 2012 )3 10. Decimal to hex 86= 0x( 56 ) 11. Convert the following decimal number to sign and magnitude format (8 bits) -17=10010001 12. Convert the following decimal number to 1’s complement (8 bits) -17=11101110 13. Convert the following decimal number to 2’s complement (8 bits) -17=11101111 14. Convert the following decimal number to IEEE 754 ( 32 bits) 47.37510=0 1000 0100 0111 1011 0000 0000 0000 000 15. Convert the following IEEE 754 to decimal number 0 10000011 010001100000000 00000000= ( 20.75 ) 16. 4 bits unsigned number addition (Overflows or not?) 0101+1100=(1)0001 there is an over flow 17. 4 bits 1’s complement addition (Overflows or not?) 1101+1010= (1)0111 there is an overflow 18. 4 bits 1’s complement addition (Overflows or not?) 1100+1000 (1) 0100 there overflow 19. 4 bits 2’s complement addition (Overflows or not?) 1101+1011=(1)1000 not 20. 4 bits 2’s complement addition (Overflows or not?) 1100+1010(1)0110...

Words: 296 - Pages: 2

Premium Essay

Netw 202 Week 5 Lab Report Latest

...SECTION 1: Converting Decimal to Binary and Binary to Decimal SECTION 11: Classifying Network Addressing NETW 202 WEEK 5 LAB REPORT LATEST SECTION 1: Converting Decimal to Binary and Binary to Decimal SECTION 11: Classifying Network Addressing NETW 202 WEEK 5 LAB REPORT LATEST SECTION 1: Converting Decimal to Binary and Binary to Decimal SECTION 11: Classifying Network Addressing NETW 202 WEEK 5 LAB REPORT LATEST SECTION 1: Converting Decimal to Binary and Binary to Decimal SECTION 11: Classifying Network Addressing NETW 202 WEEK 5 LAB REPORT LATEST SECTION 1: Converting Decimal to Binary and Binary to Decimal SECTION 11: Classifying Network Addressing NETW 202 WEEK 5 LAB REPORT LATEST SECTION 1: Converting Decimal to Binary and Binary to Decimal SECTION 11: Classifying Network Addressing NETW 202 WEEK 5 LAB REPORT LATEST SECTION 1: Converting Decimal to Binary and Binary to Decimal SECTION 11: Classifying Network Addressing NETW 202 WEEK 5 LAB REPORT LATEST SECTION 1: Converting Decimal to Binary and Binary to Decimal SECTION 11: Classifying Network Addressing NETW 202 WEEK 5 LAB REPORT LATEST SECTION 1: Converting Decimal to Binary and Binary to Decimal SECTION 11: Classifying Network Addressing NETW 202 WEEK 5 LAB REPORT LATEST SECTION 1: Converting Decimal to Binary and Binary to Decimal SECTION 11: Classifying Network Addressing NETW 202 WEEK 5 LAB REPORT LATEST SECTION 1: Converting Decimal to Binary and Binary to Decimal SECTION 11: Classifying...

Words: 515 - Pages: 3

Premium Essay

Nt1210 Ho1

...Converting Decimal to Binary…and Binary to Decimal Decimal to Binary 1. Subtract the largest decimal equivalent from the table below (“Decimal” line) from the original number. Put a “1” in the “Conversion” line of the box below. 2. Subtract next largest decimal equivalent. Put a “1” in the “Conversion” line of the box below. 3. Repeat Step 2 until you have no remainder. This is your binary number. Binary | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | Decimal | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | Conversion | | | | | | | | | EXAMPLE: Decimal number = 219 Decimal No. | Binary No. | Remainder | 219 - | 128 = | 91 | 91 - | 64 = | 27 | 27 - | 16 = | 11 | 11 - | 8 = | 3 | 3 - | 2 = | 1 | 1 - | 1 = | 0 | Binary | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | Decimal | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | Conversion | 1 | 1 | 0 | 1 | 1 | 0 | 1 | 1 | Binary number = 11011011 Hexadecimal to Binary The easiest way to convert binary to hex or hex to binary is to use the following table. Decimal | Hex | Binary | 0 | 0 | 0000 | 1 | 1 | 0001 | 2 | 2 | 0010 | 3 | 3 | 0011 | 4 | 4 | 0100 | 5 | 5 | 0101 | 6 | 6 | 0110 | 7 | 7 | 0111 | 8 | 8 | 1000 | 9 | 9 | 1001 | 10 | A | 1010 | 11 | B | 1011 | 12 | C | 1100 | 13 | D | 1101 | 14 | E | 1110 | 15 | F | 1111 | EXAMPLE (Hex to Binary): Convert 48AF to binary Use conversion table Hex: 4 8 A F Binary: 0100 1000 1010 1111 EXAMPLE (Hex...

Words: 279 - Pages: 2

Free Essay

Binary Numbers

...Binary Numbers Overview Binary is a number system used by digital devices like computers, cd players, etc.  Binary is Base 2, unlike our counting system decimal which is Base 10 (denary).  In other words, Binary has only 2 different numerals (0 and 1) to denote a value, unlikeDecimal which has 10 numerals (0,1,2,3,4,5,6,7,8 and 9).  Here is an example of a binary number: 10011100  As you can see it is simply a bunch of zeroes and ones, there are 8 numerals in all which make this an 8 bit binary number. Bit is short for Binary Digit, and each numeral is classed as a bit.  The bit on the far right, in this case a 0, is known as the Least significant bit (LSB).  The bit on the far left, in this case a 1, is known as the Most significant bit (MSB)  notations used in digital systems: 4 bits = Nibble 8 bits = Byte 16 bits = Word 32 bits = Double word 64 bits = Quad Word (or paragraph)  When writing binary numbers you will need to signify that the number is binary (base 2), for example, let's take the value 101. As it is written, it would be hard to work out whether it is a binary or decimal (denary) value. To get around this problem it is common to denote the base to which the number belongs, by writing the base value with the number, for example:  1012 is a binary number and 10110 is a decimal (denary) value.  Once we know the base then it is easy to work out the value, for example:  1012 = 1*22 + 0*21 + 1*20 = 5 (five)  10110 = 1*102 + 0*101 +...

Words: 647 - Pages: 3

Premium Essay

Compututing

...Introduction to Binary Numbers How Computers Store Numbers Computer systems are constructed of digital electronics. That means that their electronic circuits can exist in only one of two states: on or off. Most computer electronics use voltage levels to indicate their present state. For example, a transistor with five volts would be considered "on", while a transistor with no voltage would be considered "off." Not all computer hardware uses voltage, however. CD-ROM's, for example, use microscopic dark spots on the surface of the disk to indicate "off," while the ordinary shiny surface is considered "on." Hard disks use magnetism, while computer memory uses electric charges stored in tiny capacitors to indicate "on" or "off." These patterns of "on" and "off" stored inside the computer are used to encode numbers using the binary number system. The binary number system is a method of storing ordinary numbers such as 42 or 365 as patterns of 1's and 0's. Because of their digital nature, a computer's electronics can easily manipulate numbers stored in binary by treating 1 as "on" and 0 as "off." Computers have circuits that can add, subtract, multiply, divide, and do many other things to numbers stored in binary. How Binary Works The decimal number system that people use every day contains ten digits, 0 through 9. Start counting in decimal: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, Oops! There are no more digits left. How do we continue counting with only ten digits? We add a second...

Words: 1301 - Pages: 6

Premium Essay

Nt1210

...Izaak Cook NT 1210 Intro to Networking Unit 1. Lab 1.2: Binary Math and Logic Exercise 1.2.1 1 0 0 1 + 1 1 0 Binary 1111 = 15 Decimal 2. Exercise 1.2.2 1 1 0 1 0 1 Binary 1011 = 11 Decimal 3. Exercise 1.2.3 1 1 1 1 1 1 Binary 1110 = 14 Decimal 4. Exercise 1.2.4 100 2 OR 011 2 = 111 = 7 5. Exercise 1.2.5 111 2 AND 100 2 = 100 = 4 6. Exercise 1.2.6 NOT 1001 2 = 0110 2 = 6 Exercise 1.2.7 1010 2 + 10 2 = 1100 2 + 10 2 (= 2) = 1110 2 Exercise 1.2.8 If one of the values being added is 11112, then the result will be the same as the other value being added. Exercise 1.2.9: 1 | 1 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | Using the OR operator, what is the result of 11002 OR 11112? What can you conclude about using OR on any value with a string of 1s? What value can you use with an OR operator to preserve the other input number in the logical equation? When using a string of 11112 the result will be the same using 111121.2 review 1. Determine the result of 100100002 + 11011102. Show the mapping that you created to solve this addiTon problem. 100100002 11011102 111111104 = 254 decimal 2. Determine the result of 110011002 AND 111111002. Show the mapping or truth table that you created to solve this addiTon problem. 110011002 111111002 1.3 Exercise...

Words: 266 - Pages: 2

Premium Essay

Binary

...understand the conversion from binary to decimal numbers and decimal to binary numbers, quickly and easily….  Decimal to Binary Decimal numbers use Base 10 Binary numbers use Base 2 8 bits = 1 Byte Study the following chart and the comments by each line or section…    |   | 8  bits | 7  bits | 6 bits | 5 bits | 4 bits | 3 bits | 2 bits | 1bit | Base 2 |   | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | DecimalWeight value of each bit |   | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | Decimal to binary… | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |   | 2 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 |   | 3 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 |   | 4 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |   | 5 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 |   | 6 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | Do you see the pattern?  1 = 00000001 0+0+0+0+0+0+1 (the 1 bit is in the 20 position, the 20 position value="1). 2 = 00000010 0+0+0+0+0+0+1+0 = (the 1 is in the 21 position, the 21 position value="2) 3 = 00000011 0+0+0=0+0+0+1+1 = (the 1 is in the 21 and 20 positions, the 20 value="1" and the  21 value="2" therefore, 2 +1 = 3).  4 = 00000100 0+0+0+0+0+1+0+0 = (the 1 is in the 22 position. The 22 value="4) Always start from left to right on the chart (highest to lowest number). Try the following exercises… Change the following decimal numbers into binary and vice-versa. I have done the first one for you, you do the rest... Make sure you know where your digits are coming from…  Decimal | Binary | “Reasoning” | Ex. 234 | 11101010...

Words: 395 - Pages: 2

Free Essay

Nt 1210

...NT-1210 Unit Name Lab l Labs Date 1-l Reading Binary Convert the following decimal numbers to binary equivalents: 89 1011001 776 10110000 Convert the following Binary values to their decimal equivalent: 101_0100L 169 11101010 234 Lab 1-2 Binary Math and Logic Draw the graphical symbol Explain the logical operations (give a truth table) for each: AND OR NOT Lab 1.3 Bit and Byte Structure - (see page 15 of lab manual) How many bits are in a byte? 8 1 Kilobyte is equal to: 1024 55,296 23,552 bytes Kilobytes Megabytes Terabytes 54 Megabyte is equalto: 23 Gigabyte is equalto: 5 Terabyte is equal to 5,120 120MB = 16GB= 125,829,120 16,384 bytes MBytes Lab 1.4 ASCII (See page 20 of Lab manual) 1. Decode the simple numerical sentences into one English paragraph. You may use Google to find an ASCII table. Use the keywords-Binary to text conversion; Hexadecimatto text conversion; ASGllto text conversion-to aid the decoding process: Code"Tvoe ASC llcodes Numeric Message 87 101 1 08 1 08 44 32 116 104 97 116 32 109 97 107 101 115 32 111 117 114 32 49 48 32 110 117 109 98 101 114 32 100 101 99 105 109 97'108 3247 3297 115 99 105 10532115121115116 101 '10932 106 117 11511632114105103104 11633148 Translation Well, that makes our 10 number decimal / ASCII system just right! Lab 1.5 Creating a File System Follow the procedures outlined in the Lab Manual on pages 231o27 Exercise...

Words: 918 - Pages: 4

Free Essay

Lab 6

...University of West Florida Electrical and Computer Engineering Digital Logic and Computer Systems EEL 3701L Lab 6: BCD to Seven Segment Display Decoder Due: November 3, 2014 Meghan Szatkowski, Brandon Burrows, Michael Long Abstract: For this lab we were to create a circuit that displays decimal numbers from binary numbers since most humans are not capable of reading binary. Using a 7-segment display we are able to achieve that by converting the BCD value into a 7 bit output. The 7-segment display has 7 LEDs and a certain amount of voltage triggers each of the 7 segments to produce a decimal number. Procedure 1. Create a truth table for your 4 bit input and the corresponding output necessary to light the proper segments of the display. For example, if the input is represented by WXYZ and the output is identified as ABCDEFG then if the input is 0000, all outer LEDs should be lit while the middle LED should be off. Once you create the rows in a truth table for the other 9 combinations, find the function for each segment. 2. Depending on whether you are dealing with more 0s or 1s, choose NAND or AND gates to implement each segment function. 3. Wire the input DIP switches to the decoder input. Note that you have 2 3x8 decoders. You will need to use the inputs and enable lines to combine them in order to implement these 7 functions. 4. Wire the NAND or AND gates to the proper outputs of the decoders in order to implement the functions for each segment...

Words: 1151 - Pages: 5

Free Essay

None

...1. Use what you’ve learned about the binary numbering in this chapter to convert the following decimal numbers to binary? * 11= 00001011 * 65= 01000001 * 100= 01100100 * 255= 11111111 2. Use what you’ve learned about the binary numbering system in this chapter to convert the following binary numbers to decimal? * 00001101=13 * 00001000=8 * 00101011=43 3. Look at the ASCII chart in Appendix A on CD that accompanies this book and determine the codes for each letter of your name? * 67 97 114 108 111 115 78 97 106 101 114 97 * C a r l o s N a j e r a 4. Use the web to research the history of the BASIC, C++, Java, and Python programming languages, and answer the following questions? * Who was the creator of each language? * When was each of these languages created? * Was there a specific motivation behind the creation of these languages? If so, what was it? * Basic was created by John George Kemeny. It was created on 1964. * C++ was created by Bjarne Stroustrup. It was created on 1979. * Java was created by Dr. James A. Gosling. It was created on 1995. * Python was created by Guido van Rossum. It was created on 1991. * The motivation behind the development of computer programming languages such as C ++, Basic, Java, and Python is that once written, a function may be used several times without rewriting it over and over. Programming languages can be used to...

Words: 259 - Pages: 2

Free Essay

Et1220 Module 1 Lab Report

...gained during your experimentation to complete the answers. * Be sure to submit your lab report before the deadline. ------------------------------------------------- Part 1- Binary-to-Decimal Number Conversion Theory: 1. Enter the decimal, hexadecimal, and BCD numbers for each of the following binary numbers. Binary | Hexadecimal | BCD | Decimal | 0000 | 0 | 0000 | 0 | 0001 | 1 | 0001 | 1 | 0010 | 2 | 0010 | 2 | 0011 | 3 | 0011 | 3 | 0100 | 4 | 0100 | 4 | 0101 | 5 | 0101 | 5 | 0110 | 6 | 0110 | 6 | 0111 | 7 | 0111 | 7 | 1000 | 8 | 1000 | 8 | 1001 | 9 | 1001 | 9 | 1010 | A | Invalid | 10 | 1011 | B | Invalid | 11 | 1100 | C | Invalid | 12 | 1101 | D | Invalid | 13 | 1110 | E | Invalid | 14 | 1111 | F | Invalid | 15 | 2. Explain major differences between binary and BCD numeric representations. Ans 2: BCD each digit of a decimal number is coded as a 4 bit binary number between 0 and 9. This is not used too often as it is difficult to do calculations in BCD as opposed to binary, and it is not efficient – uses more bits than a binary coded number would.  In Binary the number is converted to base 2, binary code.  Planning: 1. Provide a list of places that you can obtain the datasheets for the following components: * SN74LS47 Binary to BCD Decoder http://www.onsemi.com/pub_link/Collateral/SN74LS47-D.PDF * MAN72 Seven Segment Display http://web.ece.ucdavis.edu/~bbaas/180a/Datasheets/man72a.pdf * 4116R...

Words: 1024 - Pages: 5

Free Essay

Unit 1 Mm250

...source and tell me exactly what you provided as input. For example, if you used Excel to compute 16 * 16, tell me “I typed =16*16 into Excel and got 256. You may type your answer right into this document. Part I. Basic Computations 1. (3 points) Convert the binary form (base 2) to decimal form (base 10): 01110111 base 2 |128 | |115/2 | | |Decimal | |M |77 | |u |117 | |s |115 | |i |105 | |c |99 | |Capitol M | |77/2 | |Lowercase u | | | |117/2 | |Lowercase i | |105/2 | |Lowercase c | |99/2 | ANS: 1001101 1110101 1110011 1101001 1100011 Decimal...

Words: 601 - Pages: 3

Free Essay

Business Networking

...BUSINESS DATA COMMUNICATIONS HOMEWORK 1 – BINARY CALCULATIONS (13 PTS MAX) 1. Use the ASCII code to indicate the 7-bit code representation for the following: .5 pts each A. T 1010100 B. ! 0100001 C. g 1100111 D. r 1110010 2. Now, add odd parity to each of the codes in problem 1A and 1B above, placing the parity bit in the most significant digit. Add even parity to each of the codes in problem 1C and 1D above, placing the parity bit in the most significant digit. .5 pts each A. T 01010100 B. ! 10100001 C. g 11100111 D. r 01110010 3. What are the capabilities of even single bit parity? .5 pts each A. It can detect the presence of errors when there are how many errors present? B. It can correct how many errors? C. How are these capabilities different for odd parity? 4. Determine the decimal equivalent value for each of the following binary numbers .5 pts each A. 10101011 171 B. 10011101 157 C. 11100111 231 5. Determine the binary representation for each of the following decimal numbers. .5 pts each A. 139 10001011 B. 272 100010000 (more than 8 bit since the number is greater then 255) C. 79 01001111 6. How many bits are needed to uniquely represent a code that contains: .5 pts each A. 312 different symbols 2^9 = 9 bits B. 195 different symbols 2^8 = 8 bits C. 45 different symbols 2^6 = 6 bits 7. The Canon EOS 1200D/Rebel T5 digital camera has the potential to provide...

Words: 459 - Pages: 2

Free Essay

Chapter 1 Lab

... 0 1 0 1.1.6 156-128=28 28-16=12 12-8=4 4-4=0 128 64 32 16 8 4 2 1 1 0 0 1 1 1 0 0 = 1001110=156 1.1.7 255-128=127 127-64=63 63-32=31 31-16=15 15-8=7 7-4=3 3-2=1 1-1=0 128 64 32 16 8 4 2 1 1 1 1 1 1 1 1 1 =11111111=255 1.1.8 200-128=72 72-64=8 8-8=0 128 64 32 16 8 4 2 1 1 1 0 0 1 0 0 0 =11001000=200 1.2.1 111 1.2.2 1011 1.2.3 1111 1.2.4 111 1.2.5 100 1.2.6 0110 1.2.7 1110 1.2.8 1100 1.2.9 1111 1.3.1 -6400 -233 1.3.2 -6633 -There is an increase of bits. From 8 to 16, which increase the decimal number. 1.3.3 1024KB*120=122880 122880KB*1024=125829120B 1.3.4 -16*1024MB=16384MB -16384MB*1024KB=16777216KB -16777216KB*1024B=1.71798918E10 -1.7179891E10/32=536870912 words 1.3.5 -0011 0110 -0011 represents 3 -0110 represents 6 -36 1.3.6 - Change it to binary first. - F is 1111 - 6 is 0110 - 11110110 in...

Words: 334 - Pages: 2