C Programming Language
2nd Edition
ISBN: 9780131103627
Author: Brian W. Kernighan, Dennis M. Ritchie, Dennis Ritchie
Publisher: Prentice Hall
expand_more
expand_more
format_list_bulleted
Question
Chapter 2, Problem 9E
Program Plan Intro
To explain the reason why in two’s complement number system, x&(x-1) deletes the right most 1-bit in x. also use this observation to give faster version of bitcount.
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
In MIPS assembly, implement integer division using rounding (rather than truncation). This is accomplished by taking the remainder of the division and dividing it by the original divisor. If the new quotient is higher than or equal to one, multiply it by one.Otherwise, leave the original quotient alone.In MIPS assembly, implement integer division using rounding (rather than truncation). This is accomplished by taking the remainder of the division and dividing it by the original divisor. If the new quotient is higher than or equal to one, multiply it by one.Otherwise, leave the original quotient alone.In MIPS assembly, implement integer division using rounding (rather than truncation). This is accomplished by taking the remainder of the division and dividing it by the original divisor. If the new quotient is higher than or equal to one, multiply it by one.Otherwise, leave the original quotient alone.In MIPS assembly, implement integer division using rounding (rather than truncation).…
Perform each of the below computation using IEEE-754 single precision
representation. [Method: Convert both the given decimal values to IEEE-754 single
precision representation. Perform IEEE-754 computation and write the result in
hexadecimal. Convert the IEEE-754 single precision hexadecimal result back to
decimal value]. Clearly show all the steps. I
a. 3.375 + 7.25 =
b. 3.375 – 7.25 =
Implement a shift and add multiplier in Verilog to multiply two 4 bit numbers. It should becapable of multiplying both positive and negative numbers. Negative numbers arerepresented in 2’sC representation.
Chapter 2 Solutions
C Programming Language
Ch. 2 - Prob. 1ECh. 2 - Write a loop equivalent to the for loop above...Ch. 2 - Write the function htoi(s), which converts a suing...Ch. 2 - Write an alternate version of squeeze(s1,s2) that...Ch. 2 - Prob. 5ECh. 2 - Prob. 6ECh. 2 - Prob. 7ECh. 2 - Prob. 8ECh. 2 - Prob. 9ECh. 2 - Rewrite the function lower, which converts upper...
Knowledge Booster
Similar questions
- An interesting application of a PLA is conversion from the old, obsolete punched cards character codes to ASCII codes. The standard punched cards that were so pop- ular with computers in the past had 12 rows and 80 columns where holes could be punched. Each column corresponded to one character. so each character had a 12-bit code. However, only 96 characters were actually used. Consider an application that reads punched cards and converts the character codes to ASCII. a. Describe a PLA implementation of this application. b. Can this problem be solved with a ROM? Explain.arrow_forwardImplement the modular exponentiation (a.k.a. fast exponentiation) function mod_exp (b, n, m) to compute bn (mod m) more efficiently. (Hint: to read n bit-by-bit, use / and % operations repeatedly) a) Test your function for b = 3, n = 231 – 2, m = 231 – 1. b) Report the result and the time (in seconds) it takes to find the result. Q3. [30 pts] Modify your is_prime function to use the mod_exp (b, n, m) instead of the standard power operation (b**n % m). Rename it as is_prime2. Modify the mersenne (p) function to use is_prime2, and call it mersenne2. a) Use the modified function mersenne2 to print all the Mersenne primes Mp for p between 2 and 31 if possible, (with k = 3 in the is_prime function). Compare the results with the ones found in Q1. b) Gradually increase the range of p to find more Mersenne primes (say up to p = 101 if possible). What is the largest Mersenne prime you can achieve here? c) Extend the work in part (b) and find the maximum Mersenne prime you can get from this…arrow_forwardScenario: In a biased N-bit binary number system with bias B, positive and negative numbers are represented as their value plus the bias B. For example, for 5-bit numbers with a bias of 15, the number 0 is represented as 01111, 1 as 10000, and so forth. Biased number systems are sometimes used in floating point mathematics. Consider a biased 8-bit binary number system with a bias of 12710 Question: What is the representation and value of the most negative number?arrow_forward
- Challenge: Use MIPS(MARS) to create a program that takes an 8-bit binary number and returns it as a binary-coded decimal (BCD).arrow_forwardplease code in python Find the expanded DNA strand: this is the opposite of the compression technique described in 3. So, it basically undoes the compressing. For example, CAGGTTT is the expanded form of CA2G3T, TATTGC is the expanded form of TA2TGC, and TAGC is the expanded form of TAGC.arrow_forwardWrite MIPs program that will read two intergers from the user and compute for the sum and difference of the two intergers. Ask the user whether he wants to repeat the program : "[Y/y] / [N/n] ?".arrow_forward
- The GMP library, using C or C++ The prefered solution is to use the Sage library. 2 Fermat test 1. Implement the Fermat test of primality with small integers. 2. Write a function to generate random k-bit prime numbers. 3 RSA 1. Write the key-generation function function of RSA. The function should generate two random primes p and q of size k/2 bits. 2. Implement the RSA encryption function 3. Implement the RSA decryption function 4. Check that decryption worksarrow_forwardIn a two's complement number system, x &= (x-1) deletes the rightmost 1-bitin x. Explain why. Use this observation to write a faster version of bitcount.arrow_forwardConsider the decimal number (-48.325). Write down binaryrepresentation of this number using the IEEE 745 single precision format. Clearly specify “Sign”, “Exponent” and “Mantissa” fields of the single precisionrepresentation.arrow_forward
- Consider an 8-bit variable that we want to use for storing real numbers. We decided touse 3 bits for storing the fractional part of the number. What are the minimum andmaximum values that we can store this way. What is the numerical error when storingvalue −7.6?arrow_forwardIn this problem, you will design a circuit that encrypts (plaintext to cipher) and decrypts (cipher to plaintext) ASCII characters. The relationship between the plaintext character and cipher character is shown in the table below: plaintext character cipher character 1-? A-O P-Z space t-~ 0 In this table, the "0" and "1" refer to the characters "0" and "1", not the numerical values. Additionally, the circuit only needs to account for character listed in the table. The circuit has nine bits of input: • d = d7... do: an eight-bit number that is the binary representation of the input ASCII character • e: a single bit indicating if the circuit should encrypt (e = 1) or decrypt (e = 0) the given character The circuit has eight bits of output: • r = r7...ro: an eight-bit number that is the binary representation of the output ASCII character Draw the implementation of the circuit. The circuit does not have to be transistor-minimal; you are encouraged to use various combinational circuitry to…arrow_forwardYou are given two bit locations, I and j, together with the 32-bit values N and M. To insert Minto N, create a method that starts M at bit j and finishes it at bit i. It is safe to presume that all of M can fit in the bits j through i. Therefore, you may infer that there are at least 5 bits between j and I if M = 10011. M could not completely fit between bit 3 and bit 2, thus you would not, for instance, have j = 3 and I = 2.EXAMPLE Key in: NN 10000000000, M 10001001100 as outputarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education