Questions tagged [signed]

In computing, signedness is a property of data types representing numbers in computer programs.

A numeric variable is signed if it can represent both positive and negative numbers, and unsigned if it can only represent non-negative numbers (zero or positive numbers).

As signed numbers can represent negative numbers, they lose a range of positive numbers that can only be represented with unsigned numbers of the same size (in bits) because roughly half the possible values are non-positive values. Unsigned variables can dedicate all the possible values to the positive number range.

For example, a Two's complement signed 16-bit integer can hold the values −32768 to 32767 inclusively, while an unsigned 16 bit integer can hold the values 0 to 65535. For this sign representation method, the leftmost bit (most significant bit) denotes whether the value is positive or negative (0 for positive, 1 for negative).

Reference

980 questions
-5
votes
1 answer

Can not flip sign

I found a weird bug that happens when i try to flip the sign of the number -9223372036854775808, which does simply nothing. I get the same number back or at least that's what the debugger shows me. Is there a way to solve this without branching?…
Platin21
  • 3
  • 4
-5
votes
1 answer

Binary search two unsigned integers

A function which inputs two unsigned integers a and b and finds whether the lowest byte of b appears exactly as it is in a (starting at any position) or not. ex: Enter a:53 Enter b:13 Binary of b: 00000000 00000000 00000000 00001101 …
Kont Dooku
  • 48
  • 2
  • 12
-6
votes
1 answer

Output of the below program: Signed Byte Operation

Can someone please let me know Output of the below program and how signed byte works public class OppositeSigns { public static void main(String[] args) { // TODO Auto-generated method stub byte a =-2; byte b= -1; …
-7
votes
2 answers

Why does my program repeat forever instead of giving the maximum integer value?

I am currently learning C, and I made a program that I thought would give me the maximum integer value, but it just loops forever. I can't find an answer as to why it won't end. #include int main() { unsigned int i = 0; signed int…
-7
votes
1 answer

C data types real life example

I am new to programming. While i'm browsing for datatypes i found many data types,i understood all the other data types except signed and unsigned data types. can any one help me by giving real life examples for using signed,unsigned…
Pleotex
  • 42
  • 9
1 2 3
65
66