Question 2
(a) The 4 common ALU flags occur in most computers. Some computers have additional ALU flags. For example, the x86 flag set includes P, I, and H flags, and the ARM flag set includes T, F, and I. Select two of these additional flags, and research their purpose. Indicate, if appropriate, the logic used to calculate the flag value for a given ALU operation.
(b) An ALU can be used to compare two values, by subtracting the values and consulting the flags. For example, if the two values were the same, the zero flag will be active after they are subtracted. When subtracting A-B, which flags should be active to indicate A<B and A>B for signed numbers? Justify your reasoning.
BONUS: indicate which flags should be active for unsigned comparisons A<B, A>B, A=B
In: Computer Science
var1 db “b, “ca”, 0
var2 db 3, 0, 0, 0
var3 times 2 dw 012h
mov eax, var3
mov ebx, var1
sub eax, 4
add ebx, [eax]
mov dword [ebx], 42
Show work on each step.
Show final memory starting at "var1" on a Little-Endian Machine.
In: Computer Science
Represent the value -65.75 in single and double precision. Please show all work.
In: Computer Science
A bowling team consists of five players. Each player bowls three games. Write a program, in python, that uses a nested loop to enter each player’s name and individual scores (for three games). You will use one variable for the name and only one variable to enter the scores. Do not use score1, score2, and score3. Compute and display the bowler’s name and average score. Also, calculate and display the average team score.
YOU MUST USE A NESTED LOOP FOR CREDIT.
In: Computer Science
In: Computer Science
Complete the following in syntactically correct Python code.
1. The program should display a message indicating whether the person is an infant, a child, a teenager, or an adult.
Following are the guidelines:
a. If the person is older than 1 year old or less, he or she is an infant.
b. If the person is older than 1 year, but younger than 13, he or she is a child
c. If the person is at least 13 years old, but less than 20 years old, he or she is a teenager.
d. If the person is at least 20 years old, he or she is an adult.
In: Computer Science
Where the OOD approach is specified use a separate test class to create your objects.
In: Computer Science
Explain the following: a bit, octet, hexadecimal, and decimal value
In: Computer Science
how do you get the sum of all elements in a stack in c++ ?
In: Computer Science
What kinds of materials on the internet are protected by copyright law?
Essentially every image, text, sound, and video that has not specifically been released for public use by its legal owner. |
||
Essentially every image, text, sound, and video if it is on a .com domain. |
||
Only those images, texts, sounds, and videos that have legally filed for copyright. |
||
Any image, text, sound, and video with a copyright statement or © icon. |
In: Computer Science
Code in python
Hello I want a program to read only the price of each line in a txt file in python. The price is present right after the 2nd comma within the txt file. The output that I want is also printed at the bottom.
Inside the txt file:
2019-08-01 00:08:39,BTC/USD,10128.08
2019-08-01 00:08:21,BTC/USD,10117.54
2019-08-01 00:08:20,BTC/USD,10120.51
2019-08-01 00:08:19,BTC/USD,10118.13
2019-08-01 00:08:18,BTC/USD,10120.74
Python file output:
Price 1: 10128.08
Price 2: 10117.54
Price 3: 10120.51
Price 4: 10118.13
Price 5: 10120.74
In: Computer Science
Lab Assignment Objectives
Understand the Application
Complex Numbers
A complex number, c, is an ordered pair of real numbers (doubles). For example, for any two real numbers, s and t, we can form the complex number:
This is only part of what makes a complex number complex. Another important aspect is the definition of special rules for adding, multiplying, dividing, etc. these ordered pairs. Complex numbers are more than simply x-y coordinates because of these operations. Examples of complex numbers in this format are (3, 3), (-1, -5), (1.034, 77.5) and (99.9, -108.5). You will build a class of complex numbers called Complex.
One important property of every complex number, c, is its length, or modulus, defined as follows. If c = (s, t) then:
For example:
The Program Specification
Create a class of Complex numbers.
Private Data
Public Instance Methods
Division By Zero
Create your own DivByZeroException as a nested class.
Make sure that both your reciprocal() and operator/() functions throw this exception (you can do this by only throwing it for reciprocal() if you do it correctly). Test it out in your client with a try/catch block, attempting both a normal, and a fatal division.
To test for division by zero, look at the reciprocal() and test for that being zero. However, not to test for == 0.0 exactly, because of inaccuracies in computer storage of doubles. Instead, pick a literal like .00000001 and proclaim the a complex object to be zero if its modulus (or modulus squared) is less than that literal value.
Description of the Operators
Operators +, -, * and /
Provide four overloaded operators, +, -, * and /. Implement these operators as friend methods of the class, so that Complex objects can be combined using these four operations. Also, allow a mixed mode operation containing a double and a Complex (which would return a Complex), by treating a double x, as if it were the complex number (x,0). This should come about naturally as a result of the Complex/Complex operators and the proper constructor definitions, not by creating 3 overloads for each operator.
The rules for adding complex numbers are:
(r,i) + (s,j) = (r + s, i + j).
Subtraction is defined analogously. Multiplication is defined by the rule:
(r,i) * (s,j) = (r*s - i*j, r*j + s*i).
To define division, first define the operation reciprocal of the complex number c = (r,i) as follows. c.reciprocal() should return the complex number = ( r / (r*r + i*i), -i / (r*r + i*i) ), if (r*r + i*i) is not zero. If (r*r + i*i) is zero, then reciprocal() throws an exception.
Then define division with the help of the reciprocal() function (informally):
(r,i) / (s,j) = (r,i) * reciprocal(s,j)
Notice that if you correspond a normal double number x, with its complex counterpart, (x,0), then you can think of the ordinary double numbers as a subset of the complex numbers. Also, note that, under this correspondence, these four operations result in ordinary addition, multiplication, etc. for the double subset. Try adding or dividing (6,0) and(3,0) for an example.
Testing Specification
In summary, you should be able to handle the combinations below:
Complex a(3,-4), b(1.1, 2.1), c; double x=2, y= -1.7; c = a + b; c = x - a; c = b * y; // and also: c = 8 + a; c = b / 3.2;
To help you confirm your computations, here are some examples:
(1, 2) + (3, 4) = (4, 6) (1, 2) - (3, 4) = (-2, -2) (1, 2) * (3, 4) = (-5, 10) (1, 2) / (3, 4) = (0.44, 0.08) (1, 2) + 10 = (11, 2) 10 / (3, 4) = (1.2, -1.6)
Operators << and =
Overload the insertion and assignment operators in the expected ways.
Operators < and ==
a < b should mean |a| < |b|, that is, a.modulus() < b.modulus(). a == b should mean (a.real == b.real) && (a.imag == b.imag). Define these two operators to make this so. (Note: < is not standard in math; there is no natural ordering mathematically for complex numbers. However, we will allow it to be defined this way in the problem.)
Pass all Complex parameters as const & and return all values of functions that sensibly return complex numbers (like operator+(), e.g.) as Complex values (not & parameters).
What to Turn In
To avoid Canvas adding a number to your complex files (i.e. same names as lab 5) prepend your initials.
For example: Ann Ohlone would be handing in the 3 files: aocomplex.h, aocomplex.cpp, a6.cpp
Hand in 3 files: No zip files.
In: Computer Science
In: Computer Science
REGARDING RISK ASSESSMENT
WRITE A REFLECTION ON THE TOPIC RISK MITIGATION
MUST HAVE AN INTRODICTION -BODY-CONCLUSION
MUST BE 500 WORDS
PLEASE MAKE COPY PASTE AVAILABLE
In: Computer Science
The code is bellow. follow this instructions to edit the code :
lets assume that instead of the maximum and minimum values, you want to find the 2nd largest/smallest. For example, in the numbers 1 to 10, this would return 2 and 9 .you will have to change the "max_min" function accordingly. this has a different puepose than "max_min", so you must give it another name.
code:
#include <stdio.h>
#define N 235
void max_min (int a[], int n, int *max, int *min);
int main()
{
int b[N],i,big,small,n;
printf("Enter the Number of elements in the array\n");
scanf("%d",&n);
printf("Enter %d Numbers: \n",n);
for(i=0;i<n;i++)
scanf("%d",&b[i]);
max_min(b,n,&big,&small);
printf("Largest %d\n",big);
printf("Smallest %d\n",small);
return 0;
}
void max_min(int a[], int n, int *max, int *min)
{
int i;
*min=*max=a[0];
for(i=1;i<n;i++)
{
if(a[i]>*max)
*max=a[i];
else if(a[i]<*min)
*min=a[i];
}
}
In: Computer Science