COMPUTER SYSTEMS&MOD MSGT/ET SA AC PKG
3rd Edition
ISBN: 9780134671123
Author: Bryant
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 2, Problem 2.64HW
Write code to implement the following function:
/* Return 1 when any odd bit of x equals 1; 0 otherwise.
Assume w = 32 */
int any_odd_one(unsigned x);
Your function should follow the bit-level integer coding rules (page 128), except that you may assume that data type int has w = 32 bits.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Can you write a c++ code using loop statement for table 44
Computer Science
it has to be done in c programming
// Task 3
// For this function, you must return the largest power of 2 that// is less than or equal to x (which will be positive). You may// not use multiplication or some sort of power function to do this,// and should instead rely on bitwise operations and the underlying// binary representation of x. If x is 0, then you should return 0.unsigned largest_po2_le(unsigned x) {return x;}
Language: C
Write the definition of the function
bool odd (unsigned char data);
which checks is the value passed to the function is odd or not by returning true or false, respec-
tively. The function has to use bitwise operators and is not allowed to use arithmetic operators.
Chapter 2 Solutions
COMPUTER SYSTEMS&MOD MSGT/ET SA AC PKG
Ch. 2.1 - Practice Problem 2.1 (solution page 143) Perform...Ch. 2.1 - Prob. 2.2PPCh. 2.1 - Prob. 2.3PPCh. 2.1 - Practice Problem 2.4 (solution page 144) Without...Ch. 2.1 - Prob. 2.5PPCh. 2.1 - Prob. 2.6PPCh. 2.1 - Prob. 2.7PPCh. 2.1 - Prob. 2.8PPCh. 2.1 - Practice Problem 2.9 solution page 146 Computers...Ch. 2.1 - Prob. 2.10PP
Ch. 2.1 - Prob. 2.11PPCh. 2.1 - Prob. 2.12PPCh. 2.1 - Prob. 2.13PPCh. 2.1 - Prob. 2.14PPCh. 2.1 - Prob. 2.15PPCh. 2.1 - Prob. 2.16PPCh. 2.2 - Prob. 2.17PPCh. 2.2 - Practice Problem 2.18 (solution page 149) In...Ch. 2.2 - Prob. 2.19PPCh. 2.2 - Prob. 2.20PPCh. 2.2 - Prob. 2.21PPCh. 2.2 - Prob. 2.22PPCh. 2.2 - Prob. 2.23PPCh. 2.2 - Prob. 2.24PPCh. 2.2 - Prob. 2.25PPCh. 2.2 - Practice Problem 2.26 (solution page 151) You are...Ch. 2.3 - Prob. 2.27PPCh. 2.3 - Prob. 2.28PPCh. 2.3 - Prob. 2.29PPCh. 2.3 - Practice Problem 2.30 (solution page 153) Write a...Ch. 2.3 - Prob. 2.31PPCh. 2.3 - Practice Problem 2.32 (solution page 153) You are...Ch. 2.3 - Prob. 2.33PPCh. 2.3 - Prob. 2.34PPCh. 2.3 - Practice Problem 2.35 (solution page 154) You are...Ch. 2.3 - Prob. 2.36PPCh. 2.3 - Practice Problem 2.37 solution page 155 You are...Ch. 2.3 - Prob. 2.38PPCh. 2.3 - Prob. 2.39PPCh. 2.3 - Practice Problem 2.40 (solution page 156) For each...Ch. 2.3 - Prob. 2.41PPCh. 2.3 - Practice Problem 2.42 (solution page 156) Write a...Ch. 2.3 - Practice Problem 2.43 (solution page 157) In the...Ch. 2.3 - Prob. 2.44PPCh. 2.4 - Prob. 2.45PPCh. 2.4 - Prob. 2.46PPCh. 2.4 - Prob. 2.47PPCh. 2.4 - Prob. 2.48PPCh. 2.4 - Prob. 2.49PPCh. 2.4 - Prob. 2.50PPCh. 2.4 - Prob. 2.51PPCh. 2.4 - Prob. 2.52PPCh. 2.4 - Practice Problem 2.53 (solution page 160) Fill in...Ch. 2.4 - Practice Problem 2.54 (solution page 160) Assume...Ch. 2 - Compile and run the sample code that uses...Ch. 2 - Try running the code for show_bytes for different...Ch. 2 - Prob. 2.57HWCh. 2 - Write a procedure is_little_endian that will...Ch. 2 - Prob. 2.59HWCh. 2 - Prob. 2.60HWCh. 2 - Prob. 2.61HWCh. 2 - Write a function int_shifts_are_arithmetic() that...Ch. 2 - Fill in code for the following C functions....Ch. 2 - Write code to implement the following function: /...Ch. 2 - Write code to implement the following function: /...Ch. 2 - Write code to implement the following function: / ...Ch. 2 - You are given the task of writing a procedure...Ch. 2 - Prob. 2.68HWCh. 2 - Write code for a function with the following...Ch. 2 - Write code for the function with the following...Ch. 2 - You just started working for a company that is...Ch. 2 - You are given the task of writing a function that...Ch. 2 - Write code for a function with the following...Ch. 2 - Write a function with the following prototype: /...Ch. 2 - Prob. 2.75HWCh. 2 - The library function calloc has the following...Ch. 2 - Prob. 2.77HWCh. 2 - Write code for a function with the following...Ch. 2 - Prob. 2.79HWCh. 2 - Write code for a function threefourths that, for...Ch. 2 - Prob. 2.81HWCh. 2 - Prob. 2.82HWCh. 2 - Prob. 2.83HWCh. 2 - Prob. 2.84HWCh. 2 - Prob. 2.85HWCh. 2 - Intel-compatible processors also support an...Ch. 2 - Prob. 2.87HWCh. 2 - Prob. 2.88HWCh. 2 - We are running programs on a machine where values...Ch. 2 - You have been assigned the task of writing a C...Ch. 2 - Prob. 2.91HWCh. 2 - Prob. 2.92HWCh. 2 - following the bit-level floating-point coding...Ch. 2 - Following the bit-level floating-point coding...Ch. 2 - Following the bit-level floating-point coding...Ch. 2 - Following the bit-level floating-point coding...Ch. 2 - Prob. 2.97HW
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
To make sure that you can interact with the Python interpreter, try the following steps on your computer: Star...
Starting Out with Python (4th Edition)
Big data Big data describes datasets with huge volumes that are beyond the ability of typical database manageme...
Management Information Systems: Managing The Digital Firm (16th Edition)
This optional Google account security feature sends you a message with a code that you must enter, in addition ...
SURVEY OF OPERATING SYSTEMS
ESP Game Write a program that tests your ESP (extrasensory perception). The program should randomly select the ...
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Suppose you are given 32 processors, each capable of finding the sum of two multidigit numbers in a millionth o...
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
T F C++ allows you to partially initialize an array.
Starting Out with C++ from Control Structures to Objects (9th Edition)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- (Numerical) Using the srand() and rand() C++ library functions, fill an array of 1000 floating-point numbers with random numbers that have been scaled to the range 1 to 100. Then determine and display the number of random numbers having values between 1 and 50 and the number having values greater than 50. What do you expect the output counts to be?arrow_forwardplease use python function should do the following: when the function input is ([[11, 11, 11, 11, 11], [1, 5, 5, 5, 7], [255, 255, 255, 0, 255]]) the output should be [['11x5'], ['1x1', '5x3', '7x1'], ['255x3', '0x1', 255x1']] functions/methods (please DO NOT use functions that are not specified here):sum() min() max() list append() list insert() list remove() list pop() list count() list index() list sort() str capitalize() str isupper() str strip() str split() str join() id() len() str lower() str upper() str replace() str count() str find()arrow_forwardC++ only ExampleInput:215 100123456789 9876543 Output:70102768568246676arrow_forward
- Need help for SML programming lagauge. (Going from binary to decimal) I need a function called decimal (val decimal = fn: string -> int) that takes a bit string corresponding to an integer and returns the decimal value of that integer. For example, decimal "10001" returns 17, decimal "001101" returns 13. I've already done a decimal to binary though the function: fun binary(x)= if x<=1 then Int.toString(x) else binary(x div 2) ^ Int.toString( x mod 2);arrow_forwardPlease help me solve this problem with kind explanations :) We are running programs on a machine where values of type int have a 32-bit two's complement representation. Values of type float use the 32-bit IEEE format, and values of type double use the 64-bit IEEE format. We generate arbitrary integer values x, y, and z, and convert them to values of type double as follow: /* Create some arbitrary values */ int x = random(); int y = random(); int z = random(); /* Convert to double */ double dx = (double) x; double dy = (double) y; double dz = (double) z; For each of the following C expressions, you are to indicate whether or not the expression always yields 1. If it always yields 1, describe the underlying mathematical principles. Otherwise, give an example of arguments that make it yield 0. Note that you cannot use an IA32 machine running GCC to test your answers, since it would use the 80-bit extended-precision representation for both float and double. A. (double)(float) x == dx B. dx…arrow_forward(a) Write a function with the header: unsigned long factorial Func( const unsigned long n) that gets the positive integer n and calculates n! n! = n*(n-1)* (n-2)* (n-3) ... * 3 * 2 * 1; (b) The trigonometric function sin(x) can be approximately calculated using the following formula, where n! is factorial(n) - for example 3!=3*2*1 = 6 (the function in previous problem). sin z = (−1)n (2n + 1)! 2n+1 = 0 3! 5! for all c The more terms we use in the series, the higher will be accuracy of the calculations. By using infinite terms in the series we will have the exact value. Write a program that gets x and calculates sin(x) using 5, 10, 20 terms.arrow_forward
- 5. Consider an integer array x, initialized with 8 decimal values. After running this instruction =%=D> size D sizeof(x); What Hex value should be stored in the variable size. a. 8 b. 20 C. 24 d. 32 e. 36 f. None of Above 6. struct Struct (int a[20], double x} int main() {Struct s1, return 0) To initialize the elements of structure, following instrunction is the correct option: Struct al0] = 50;, b. a. Struct x = 5.0; Struct.a = (10, 20, 30, 40}; d. C. All of Above None of Above 7. 1ostream.cis for Dev C++ 1 point b. a. the header File the standard Library d. C. Input output functions file None of above e. (a && b) II (c&&d) only gives true when! a. Jany of a, b, c. d is true b. Ooth a b are true C. all a b cdare true d. abisture or cd is true e. None of abovearrow_forwardUse C++arrow_forwardWhat does the function return for any positive values of x and n ? The answer should be a general formula in terms of x and n. int what_do_I_do ( int x, int n ) { if ( n = = 1 ) return x; else return x + what_do_I_do ( x, n – 1 ); } C++ be quick pleasearrow_forward
- please complete following c++ code questionarrow_forwardThe pseudocode for implementing the Taylor series expansion is shown below. The pseudocode is designed to return the value of the value of e* correct to two decimal places. This also requires the use of the factorial function created in the previous section. INPUT x, OUTPUT ExpVal % Initial computation n- 0, xold - 0 xnew - xold + (x^n)/nl error = |xnew - xold| xold = xnew n-1 %Successive computations WHILE error 2 0.001 xnew - xold + (x^n)/nl error |xnew - xold xold - xnew n=n+1 END WHILE ExpVal = xnew Question 10: Write a script taylor.m that computes the value of the function e* for a given user input x. Provide La proof that your script works.arrow_forwardWrite a program that reads two vectors and calculate the angle in radius between these two vectors , C++arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
CPP Function Parameters | Returning Values from Functions | C++ Video Tutorial; Author: LearningLad;https://www.youtube.com/watch?v=WqukJuBnLQU;License: Standard YouTube License, CC-BY