answersLogoWhite

0


Best Answer

Nothing special: value >> number.

Example:

/* shift.c */

#include <stdio.h>

int main (void)

{

long n;

int i;

n= -98765;

for (i=0; i<20; ++i) {

printf ("%2d: %6ld %lx\n", i, n>>i, n>>i);

}

return 0;

}

output:

0: -98765 fffe7e33

1: -49383 ffff3f19

2: -24692 ffff9f8c

3: -12346 ffffcfc6

4: -6173 ffffe7e3

5: -3087 fffff3f1

6: -1544 fffff9f8

7: -772 fffffcfc

8: -386 fffffe7e

9: -193 ffffff3f

10: -97 ffffff9f

11: -49 ffffffcf

12: -25 ffffffe7

13: -13 fffffff3

14: -7 fffffff9

15: -4 fffffffc

16: -2 fffffffe

17: -1 ffffffff

18: -1 ffffffff

19: -1 ffffffff

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How to use right shift operator with negative value in c?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is a bit shift?

A bit shift is a bitwise operation in which the bits in a value are shifted left or right.


Explain the Difference between bitwise operator ' and ' and address operator ' and ' of pointer?

The bitwise logical operator and (&) calculates the bitwise logical and of two integral values. It is a binary operator.The address of (&) operator returns the address of the value to its right. It is a unary operator.The distinction between the two is one of context. The logical and operator will follow (and be preceeded by) a value, while the address of operator will follow an operator.


Which value is modified by an operator?

The value of the variable which is on the left side of the assignment operator. Example: a = 2


What is the value of 5.7 multiplied by 10?

57 because you just shift the decimal point to the right. The number of 0s is the number of times you shift the decimal. In this case 1 zero is 1 movement of decimal point. Note: if it is multplied by negative 10 it means the decimal point moves left however if it is multiplied by positive ten then the decimal point moves right.


How do you use coordinates?

Start at zero and move the value of the first number right (move left if negative) Then move up the value of the second number (down if negative)


What is the absolute value of 52?

52. The absolute value is the nonnegative value of a number. Enclosing vertical bars ( | | ) are the absolute value operator. Using that notation we can state that |a| = a, and |-a| = a. You can also note that |a| (whether a is negative or positive) equals the square root of a squared.


What is the difference between you equals 10 and you equals equals 10 in c language?

The = operator is the assignment operator. The == operator is the equality or equals operator. The = operator is the assignment operator. We use it to assign a value (the right hand operand) to an object (the left hand operand). The value must be of the same type as the object unless the value can implicitly convert to the object's type. If not, we must explicitly cast the value to the appropriate type. The operator evaluates to the value of the object after assignment, thus creating a temporary value that can be used in other expressions. Examples: int you; you = 10; // assign the value 10 to the object named 'you' int me, you; me = 10; you = 10; Note that the second example can also be written: int me, you; me = you = 10; This is because the expression 'you = 10' evaluates to the temporary value 10 (the value of 'you' after assignment) which we then assign to 'me'. Operators are evaluated according to operator precedence, and assignment 'chains' like this are always evaluated from right to left. The == operator is the equality or equals operator. We use it to determine if two object's have the same value. If so, the expression evaluates true, otherwise false. Operators that evaluate true or false are known as Boolean operators (functions that return true or false are known as predicates). Typically we use the == operator in conditional expressions: if (a == b) { // code to execute when the value of a is equal to the value of b } else { // code to execute when the value of a is not equal to the value of b } while (a == b) { // This code will loop repeatedly so long as a is equal to b at the beginning of each iteration } The == operator is one of six Boolean operators that can be used to compare object values: == : equal != : not equal &lt; : less than &lt;= : less than or equal &gt; : greater than &gt;= : greater than or equal


Complex assignment in java?

An Assignment operator in Java is the operator that is used to assign a variable a value. if you declare int x = 10; then the value 10 is assigned to the variable x. here the "=" symbol is the assignment operator.


Which operator is used to determine if the operands are not exactly of the same value?

!= is the correct operator.


Why is it not possible for the absolute value of a number to be negative?

The absolute value depends on it's "distance" from zero. So if it's to the right (positive) by 5 units, or to the left (negative) by five units, then it's absolute value is 5


What is the value of negative 9?

negative nine is the value of negative nine


What is a negative value?

A value that is negative, e.g., -5.