Computer Science

Binary Conversion

Binary conversion is the process of converting numbers or data from a decimal (base-10) system to a binary (base-2) system. In computer science, this is essential for representing and processing data in digital systems. It involves breaking down numbers into their binary equivalents, which consist of only 0s and 1s, and is fundamental to understanding how computers store and manipulate information.

Written by Perlego with AI-assistance

10 Key excerpts on "Binary Conversion"

  • Book cover image for: Principles of Modern Digital Design
    In digital systems, the binary number system and other number systems closely related to it are used almost exclusively. However, people are accustomed to using the decimal number system; hence digital systems must often provide conversion between decimal and binary numbers. The decimal value of a binary number can be formed by multiplying each power of 2 by either 1 or 0, and adding the values together. 2 NUMBER SYSTEMS AND BINARY CODES Example 1.1 Let us fi nd the decimal equivalent of the binary number 101010. N 101010 1 2 5 0 2 4 1 2 3 0 2 2 1 2 1 0 2 0 (using Eq (1 1)) 32 0 8 0 2 0 42 An alternative method of converting from binary to decimal begins with the leftmost bit and works down to the rightmost bit. It starts with a sum of 0. At each step the current sum is multiplied by 2, and the next digit to the right is added to it. Example 1.2 The conversion of 11010101 to decimal would use the following steps: The reverse process, the conversion of decimal to binary, may be made by fi rst decom-posing the given decimal number into two numbers — one corresponding to the positional value just lower than the original decimal number and a remainder. Then the remainder is decomposed into two numbers: a positional value just equal to or lower than itself and a new remainder. The process is repeated until the remainder is 0. The binary number is derived by recording 1 in the positions corresponding to the numbers whose summation equals the decimal value. Example 1.3 Let us consider the conversion of decimal number 426 to binary: 426 256 170 256 128 42 256 128 32 10 256 128 32 8 2 2 8 2 7 2 5 2 3 2 1 Thus 426 10 = 110101010 2 (the subscript indicates the value of the radix). 1.3 BINARY NUMBERS 3 An alternative method for converting a decimal number to binary is based on successive division of the decimal number by the radix number 2.
  • Book cover image for: Systems Architecture
    Basing computer processing on mathematics and physics has limits, however. Process-ing operations must be based on mathematical functions, such as addition and equality comparison; use numerical data inputs; and generate numerical outputs. These process-ing functions are sufficient when a computer performs numeric tasks, such as accounting or statistical analysis. When you ask a computer to perform tasks such as searching text documents and editing sound, pictures, and video, numeric-processing functions do have limitations, but ones that modern software has largely overcome. However, when you want to use a computer to manipulate data with no obvious numeric equivalent—for example, literary or philosophical analysis of concepts such as “mother,” “friend,” “love,” and “hate”—numeric-processing functions have major shortcomings. As the data you want to process moves further away from numbers, applying computer technology to processing the data becomes increasingly difficult—and less successful. Binary Data Representation In a decimal (base 10) number, each digit can have 1 of 10 possible values: 0, 1, 2, 3, 4, 5, 6, 7, 8, or 9. In a binary number , each digit can have only one of two possible values: 0 or 1. Computers represent data with binary numbers for two reasons: • Binary numbers represented as binary electrical signals can be transported reliably between computer systems and their components (discussed in detail in Chapter 8). • Binary numbers represented as electrical signals can be processed by two-state electrical devices that are easy to design and fabricate (discussed in detail in Chapter 4). For computer applications to produce accurate outputs, reliable data transport is important. Given current technology, binary signals and processing devices represent the most cost-efficient tradeoffs between capacity, accuracy, reliability, and cost.
  • Book cover image for: Digital Computer Structure and Design
    Decimal Codes Whatever base it may be decided to use for calculation within the computer, we are faced with the fact that in the outside world human Number Representation in Computers 71 beings prefer to think and work with numbers represented in decimal, or perhaps in one of the other units of weights and measures. It is therefore necessary to translate from decimal to binary, and vice versa, if binary is chosen as the internal number system. The translation of large numbers requires either a computer program, or a fairly elaborate hardware converter and this could not be justified for each input-output human interface, but large scale integrated circuits may make this feasible in the future. The usual solution is to split the problem into two parts, first, representing the decimal digit as a binary code, which can be done with fairly simple coding and decoding networks; and second, translating from the coded form to the true binary form by means of a program. There are a large number of possible decimal codes, but experience has eliminated all but a few, the most important being binary coded decimal (BCD), in which each decimal digit is represented by its binary equivalent, which can be seen in Table 4.1. Thus the number 437 would appear as 0100, 0011, 0111, in BCD, whereas in pure binary it would appear as 110110101, which is found by the decimal to binary con-version given earlier. The Teletype code embodies the BCD code within it, but with the added complication of extra codes for representing letters and symbols. So that in this case the BCD code is used as a communication code. The 1 out of 10 hole code used in punched cards is easily converted to BCD for input-output purposes. Another binary decimal code with important applications is the Excess 3 code. This code is formed by adding 3 to the decimal digit and converting it to binary, and has the useful property of being a self-complementing code.
  • Book cover image for: Students' Guide to Programming Languages
    • Malcolm Bull(Author)
    • 2016(Publication Date)
    • Newnes
      (Publisher)
    3: Data and data types Objectives After reading this chapter, you should be able to: • Describe the nature of binary data. • Perform binary arithmetic. • Convert binary values to their decimal equivalents, and vice versa. • Describe how a binary pattern may have more than one significance. • Describe and use the hexadecimal notation. • Convert hexadecimal values to their binary and decimal equiv-alents, and vice versa. • Describe the nature and physical appearance of the elementary data types: integer, real, character, string, Boolean, packed decimal, arrays, records, enumerated, pointers, linked lists, and sets. • Describe and use floating point numbers. • Convert floating point values to their decimal equivalents, and vice versa. • Describe and apply the naming conventions by which data types are handled in various programming languages. • Describe the concept of type checking. Types of data The computer holds all its data as a sequence of bits - binary digits. These are small, physical elements which are capable of carrying one of two possible electrical signals. These two states are conventionally used to represent the values 0 and 1 respectively, although we could equally well have chosen on and off, up and down, yes and no. 9Ί Students' Guide to Programming Languages Because each bit may be set to either of two states, 0 or 1, data repre-sented in this form is known as binary data. These bits are organized into groups of eight bits, and each group is called a byte. If we were to look at the state of the bytes on a computer we might find that one contained bits which were set to: 01110001 whilst another was set to: 01011100 Since there are 8 bits in a byte, and each bit is capable of being in either of two states, the bits in any particular byte may be set to any one of 256 possible patterns (that is, 2 to the power 8).
  • Book cover image for: Developing Windows-Based and Web-Enabled Information Systems
    • Nong Ye, Teresa Wu(Authors)
    • 2014(Publication Date)
    • CRC Press
      (Publisher)
    19 2 Digital Data Representation This chapter describes how numbers, characters, and other forms of information are repre-sented on computers using binary data. Some methods of detecting and correcting errors in data storage and transmission are also given in this chapter. 2.1 Representation of Numbers In this section, we first introduce the conversion between decimal numbers and binary numbers for unsigned numbers. We then give the representation of signed numbers. An unsigned number is a number without the negative sign. A memory address is an unsigned integer on computers. A signed number has a positive or a negative sign. Data used in computation are typically declared as signed numbers on computers. 2.1.1 Conversion between Unsigned Binary and Decimal Numbers A decimal number has a base of 10 and digit values of 0, 1, 2, …, 9. A binary number has a base of 2 and digit values of 0 and 1. The representation of a decimal number and a binary number using their base is given as follows: Decimal number: 123.45 10 = 1 × 10 2 + 2 × 10 1 + 3 × 10 0 + 4 × 10 −1 + 5 × 10 −2 Binary number: 101.01 2 = 1 × 2 2 + 0 × 2 1 + 1 × 2 0 + 0 × 2 −1 + 1 × 2 −2 The conversion of an unsigned binary number to a decimal number is carried out by computing the sum using the base representation of the binary number, as shown: 101.01 2 = 1 × 2 2 + 0 × 2 1 + 1 × 2 0 + 0 × 2 −1 + 1 × 2 −2 = 4 10 + 0 10 + 1 10 + 0 10 + 0.25 10 = 5.25 10 We use the decimal number system in our daily activities. An unsigned decimal number must be represented on computers using a binary number that is supported by computer hardware. A binary integer with N binary digits (called “bits”) can represent an unsigned decimal integer from 0 to 2 N − 1. For example, the decimal integers from 0 to 15 can be rep-resented by 4-bit binary numbers, as shown in Table 2.1. One method of converting an unsigned decimal number to a binary number is the repeated subtraction method, which has the following steps: 1.
  • Book cover image for: Numbers
    eBook - ePub

    Numbers

    Arithmetic and Computation

    • Asok Kumar Mallik, Amit Kumar Das(Authors)
    • 2022(Publication Date)
    • CRC Press
      (Publisher)
    Chapter 6 Computer and programming fundamentals
    We are now in a position to appreciate the potential of different types of numbers and their applications in describing real-life problems and their solutions. It is also expected that you might be eager to use a computer for solving some problems. Computers would be handy not only to save time, but to relieve you from the drudgery of manual computation as well. Last but not the least, computers may be a big help if you could not obtain an analytical solution.
    Here we will learn about the following, with the final goal of solving some of the problems presented in this book without the rigorous analytical acumen required otherwise.
    • How the numbers and codes are represented in computers.
    • Logic operations and logic gates.
    • How arithmetic and logic operations are done in a computer.
    • A Programming language with a tutorial introduction to programming in a concise form.
    Well, it seems to be a tall-order; believe us it would be very short and fun to learn.

    6.1 Advantages of binary representation of numbers

    In a computer the numbers are represented in binary. In fact, not only the numbers, the instruction or any other information is nothing other than some 0’s and 1’s stored in the memory, the main resource of the computer. A switch with its two states, namely, OFF and ON is the simplest possible 2-state device that be used to represent 0 and 1. So, a few switches together, say 8, may be used to represent a 8-bit binary number (b7 b6 ,…, b0 ) 000000002 to 111111112 ; i.e. 0 to 255 in decimal. Additionally, the ON and OFF states of the switches can be mapped to TRUE and FALSE in the logical domain. This is very important as the computer relies on logic operations as we shall see next.
    In short, if we choose to represent a number in decimal form, the computing system should be able to represent and identify 10 different states; 0 to 9 and carry out all arithmetic operations using 10-state devices. This leads to a complicated, costly and bulky solution. World’s first electronic computer ENIAC (1946), designed and installed in the University of Pennsylvania, USA used decimal representation of numbers. Moreover, transistors and ICs were not invented then and it was built using electronic valves. ENIAC weighed 27 tons, occupied 18,000 sq. ft. and consumed ONLY 150 KW of electricity.
  • Book cover image for: Digital Electronic Circuits
    eBook - PDF

    Digital Electronic Circuits

    Principles and Practices

    • Shuqin Lou, Chunling Yang(Authors)
    • 2019(Publication Date)
    • De Gruyter
      (Publisher)
    2.3 Conversion between number systems The conversion between number systems is to transform a number from one number system to another without changing its value. Essentially, the conversion process is the conversion of the weights between different number systems. This section intro-duces the conversion between different number systems. The objectives of this section are to – Convert from a decimal number to binary and from binary to decimal – Covert from a binary number to hexadecimal and from hexadecimal to binary – Covert from a binary number to octal and from octal to binary 2.3.1 Conversion between decimal and binary 1. Conversion from binary to decimal As mentioned in Section 2.2, the conversion from a binary number to a decimal number can be achieved directly by applying eq. (2.2.2). Example 2.1 Convert the binary number (1011.01) 2 to decimal. Solution 1011.01 ð Þ 2 = 1 × 2 3 + 0 × 2 2 + 1 × 2 1 + 1 × 2 0 + 0 × 2 − 1 + 1 × 2 − 2 = 11.25 ð Þ 10 2. Conversion from decimal to binary The process of converting a decimal number to its equivalent binary number can be divided into whole number conversion and fractional number conversion, respectively. (1) Whole number conversion A systematic method of converting a whole number from decimal to binary is the repeated division-by-2 process. For a binary whole number, its equivalent decimal number is deduced by N ½ Š 10 = b n × 2 n + b n − 1 × 2 n − 1 + + b 1 × 2 1 + b 0 × 2 0 (2 : 3 : 1) where b n is the digit at the n th position with respect to the binary point, and 2 n is the corresponding weight of b n . 2.3 Conversion between number systems 23
  • Book cover image for: The Tao of Computing
    In a typical binary machine, a common convention is that any voltage from 0 to 1.3 volts is interpreted as the digit 0, whereas voltages above 1.7 volts represent the digit 1. Having a range of voltages allows circuits to accommodate variations of voltage that may arise natu-rally. (Circuits are designed to avoid voltages between 1.3 and 1.7 volts. These intermediate voltages might be hard to interpret so such voltages may be considered errors.) With no other choices regarding possible digit values, processing can utilize simple and cheap on/ off circuits. Technically, a single 0 or 1 is called a bit of information. Such a data element is sufficient to hold the answer to a yes/no or true/false question, but a single bit is inadequate to store EXAMPLE: INTERPRETING THE DECIMAL INTEGER 36,428 In the decimal system, the location of each digit has a label (a power of 10) that indicates the relative weight of the digit Decimal number 3 6 4 2 8 ↑ ↑ ↑ ↑ ↑ Label 10,000 1000 100 10 1 (Or power of 10) 10 4 10 3 10 2 10 1 10 0 Place value (decimal number times label) 3 ∙ 10,000 6 ∙ 1000 4 ∙ 100 2 ∙ 10 8 ∙ 1 Number’s value 36,428 = 30,000 + 6000 + 400 + 20 + 8 36 ◾ The Tao of Computing more general information. Thus, in a binary system, several bits typically are grouped together in various size units, so that they can hold greater information. A particularly common grouping involves 8 bits and is called a byte . To see how natural numbers, the integers staring with 0 and going higher, can be stored in a byte, consider the following number scheme. (If you know about the binary system, this will seem quite familiar.) Note that there are eight columns, or place values, because this is an 8-bit number. The placement of each 0 and 1 influences their value. To convert a binary number into a decimal number, start at the right of a sequence of 0s and 1s, and label the digits with a power of 2. Then add the labels corresponding to where the digit 1 appears in the sequence.
  • Book cover image for: The Tao of Computing
    In a typical binary machine, a common convention is that any voltage from 0 to 1.3 volts is interpreted as the digit 0, whereas voltages above 1.7 volts represent the digit 1. Having a range of voltages allows circuits to accommodate variations of voltage that may arise naturally. (Circuits are designed to avoid voltages between 1.3 and 1.7 volts. These intermediate voltages might be hard to interpret so such voltages may be considered errors.) With no other choices regarding possible digit values, processing can utilize simple and cheap on/ off circuits.
    Technically, a single 0 or 1 is called a bit of information. Such a data element is sufficient to hold the answer to a yes/no or true/false question, but a single bit is inadequate to store more general information. Thus, in a binary system, several bits typically are grouped together in various size units, so that they can hold greater information. A particularly common grouping involves 8 bits and is called a byte.
    To see how natural numbers, the integers staring with 0 and going higher, can be stored in a byte, consider the following number scheme. (If you know about the binary system, this will seem quite familiar.) Note that there are eight columns, or place values, because this is an 8-bit number. The placement of each 0 and 1 influences their value. To convert a binary number into a decimal number, start at the right of a sequence of 0s and 1s, and label the digits with a power of 2. Then add the labels corresponding to where the digit 1 appears in the sequence. The sidebar illustrates how to find the decimal value of a binary integer. The process is quite similar to our earlier example with base 10 (the decimal system), except now the digits are labeled with powers of 2.
    EXAMPLE: COMPUTING THE DECIMAL VALUE OF A BINARY INTEGER
    In the binary system, the location of each digit has a label (a power of 2) that indicates the relative weight of the digit
    In this system, 00000000 represents the decimal number 0, 00000001 represents the decimal number 1, 00000010 represents the decimal number 2, and so forth. Following this pattern, the largest binary number would be 11111111 or 128 + 64 + … + 2 + 1 (decimal) or 255. Altogether, this approach allows us to store the integers 0 through 255, inclusive, for an 8-bit number or byte; and we can conclude that one byte of data can take on 256 different values. Of course, this range is adequate for some data storage purposes in computers, but not for others. The 8-bit number with a range of 256 alternatives will arise several times later in this chapter and throughout the book.
  • Book cover image for: Principles Of Computer Programming NQF3 SB
    • S Sasti D Sasti(Author)
    • 2019(Publication Date)
    • Macmillan
      (Publisher)
    29 Module 2 Number conversions and binary arithmetic Module 2 Overview At the end of this module, you will be able to: • Unit 2.1: Perform number conversions between different number systems. • Unit 2.2: Explain and implement encoders and decoders. • Unit 2.3: Explain and implement adding and subtracting of binary numbers. • Unit 2.4: Explain and implement binary half and full adders. Unit 2.1: Number conversions 2.1.1 Introduction As you learned in Module 1, the computer is an electronic device which understands a sequence of on or off switches, 0s or 1s. A computer therefore uses the binary number system . We, as humans, understand the decimal number system. For the computer to understand us, it has to be able to convert between the different number systems. We will now look at how to convert between the different number systems by performing arithmetic calculations and by using encoders and decoders. You will learn how to perform binary arithmetic calculations and use binary adders. 2.1.2 Number systems Definition: Number system A number system is a way of representing numbers. There are many ways to represent numbers, each with its own advantages. We will cover the following number systems in this module: l Decimal: Used in real-world calculations by humans. l Binary: Used by computers. l Octal: Used by computers. l Hexadecimal: Used by computers. Each number system has the following properties: l Name of number system. l Base. l Number of digits. l Range of digits. Table 2.1 shows the properties of the four different number systems. 30 Topic 1 Table 2.1: Properties of decimal, binary, octal, and hexadecimal number systems Number system Base Number of digits Range of digits Decimal Base 10 Represented with 10 digits. 0–9 Binary Base 2 Represented with two digits. 0 and 1 Octal Base 8 Represented with eight digits. 0–7 Hexadecimal Base 16 Represented with 16 digits and characters.
Index pages curate the most relevant extracts from our library of academic textbooks. They’ve been created using an in-house natural language model (NLM), each adding context and meaning to key research topics.