answersLogoWhite

0

If you have a 1 byte (8 bit) number, then you can use those bits in two different ways, signed and unsigned.

Unsigned means that all 8 bits represent a power of two, so you can go from 00000000 = 0 (2^0) to 11111111 = 255 (2^8 - 1).

SIgned means that you take the first bit and use it to represent positive or negative. In this case 00000001 = 1 and 10000001 = -1. So your range of values is 11111111 = -127 (-(2^7 - 1)) to 01111111 = 127.

There are a couple of problems with this simplified example, one being that you have two different representations for zero. Most computer systems use two's complement to get around this.

User Avatar

Wiki User

16y ago

What else can I help you with?

Continue Learning about Engineering

What are the four integral types in C plus plus?

There are far more than 4 integral types in C++. As of C++11, there were 27 integral types: bool char signed char unsigned char wchar_t char16_t char32_t short signed short unsigned short short int signed short int unsigned short int int signed int unsigned int long signed long unsigned long long int signed long int unsigned long int long long signed long long unsigned long long long long int signed long long int unsigned long long int


Algorithm to find factorial using functions?

factorial using recursion style in c++ is unsigned int fact(unsigned int a) { if (a<=1) return 1; else { f*=fact(a-1); return a; } } when using looping structure factorial is unsigned int fact (unsigned int n) { unsigned int i,f=1; for(i=1;i<=n;i++) f*=i ; return f; }


How to write a program to find the delimiter matching in stacks?

== == using recursions: unsigned int Factorial( unsigned int x) { if(x>0) { return ( x * Factorial(x-1)); } else { return(1); } } factorial: unsigned int Factorial( unsigned int x) { unsigned int u32fact = 1; if( x == 0) { return(1); } else { while(x>0) { u32fact = u32fact *x; x--; } } }


Is unsigned int var valid in java?

No. Java uses no unsigned numbers.


What if -1 is assigned to a unsigned variable in C plus plus?

If you assign -1 to a unsigned variable it will contain the biggest number its able to hold. For example if you assign -1 to a unsigned int it will be 4294967295 as its the biggest number a unsigned int can hold.

Related Questions

What are the four integral types in C plus plus?

There are far more than 4 integral types in C++. As of C++11, there were 27 integral types: bool char signed char unsigned char wchar_t char16_t char32_t short signed short unsigned short short int signed short int unsigned short int int signed int unsigned int long signed long unsigned long long int signed long int unsigned long int long long signed long long unsigned long long long long int signed long long int unsigned long long int


How do you generate Armstrong series in c plus plus?

#include <iostream> #include <math.h> // for std::pow() unsigned int get_length(unsigned int num,const unsigned int base=10) { unsigned int len=1; while(num && (num/=base)) ++len; return( len ); } bool is_armstrong(const unsigned int num,const unsigned int base=10) { unsigned int len=get_length(num,base); unsigned int sum=0; unsigned int tmp=num; while(tmp) { sum+=(unsigned int)std::pow((double)(tmp%base),(double)len); tmp/=base; } return(num==sum); } int main() { std::cout << "Armstrong series (base 10):"; for(unsigned int num=0; num<=0xffffffff; ++num) if(is_armstrong(num)) std::cout << " " << num; std::cout << std::endl; return(0); }


What is programme in c plus plus of a Armstrong number?

#include <iostream> #include <math.h> // for std::pow() unsigned int get_length(unsigned int num,const unsigned int base=10) { unsigned int len=1; while(num && (num/=base)) ++len; return( len ); } bool is_armstrong(const unsigned int num,const unsigned int base=10) { unsigned int len=get_length(num,base); unsigned int sum=0; unsigned int tmp=num; while(tmp) { sum+=(unsigned int)std::pow((double)(tmp%base),(double)len); tmp/=base; } return(num==sum); } int main() { std::cout << "Armstrong series (base 10):"; for(unsigned int num=0; num<=0xffffffff; ++num) if(is_armstrong(num)) std::cout << " " << num; std::cout << std::endl; return(0); }


Give the program to find Armstrong numbers between n and m in turbo c plus plus?

#include <iostream> #include <math.h> // for std::pow() unsigned int get_length(unsigned int num,const unsigned int base=10) { unsigned int len=1; while(num && (num/=base)) ++len; return( len ); } bool is_armstrong(const unsigned int num,const unsigned int base=10) { unsigned int len=get_length(num,base); unsigned int sum=0; unsigned int tmp=num; while(tmp) { sum+=(unsigned int)std::pow((double)(tmp%base),(double)len); tmp/=base; } return(num==sum); } int main() { std::cout << "Armstrong series (base 10):"; for(unsigned int num=0; num<=0xffffffff; ++num) if(is_armstrong(num)) std::cout << " " << num; std::cout << std::endl; return(0); }


Algorithm to find factorial using functions?

factorial using recursion style in c++ is unsigned int fact(unsigned int a) { if (a<=1) return 1; else { f*=fact(a-1); return a; } } when using looping structure factorial is unsigned int fact (unsigned int n) { unsigned int i,f=1; for(i=1;i<=n;i++) f*=i ; return f; }


How do you print a given integer in reverse using C plus plus?

#include <iostream> #include <time.h> unsigned int reverse( unsigned int num ) { const unsigned int base=10; unsigned int rev=0; while( num ) {rev*=base;rev+=num%base;num=num/base;} return( rev ); } int main () { srand(( unsigned ) time( NULL )); // Print 10 random numbers in reverse. for( int i=0; i<10; ++i ) {unsigned int r = ( unsigned int ) rand();std::cout << r << " = " << reverse(r) << std::endl;} return(0); }


How do you calculate the number of digits in an integer value using c programme?

#include <math.h> inline unsigned int get_num_digits(const unsigned int n) { return ((unsigned int) log10(n) + 1); }


How to write a program to find the delimiter matching in stacks?

== == using recursions: unsigned int Factorial( unsigned int x) { if(x>0) { return ( x * Factorial(x-1)); } else { return(1); } } factorial: unsigned int Factorial( unsigned int x) { unsigned int u32fact = 1; if( x == 0) { return(1); } else { while(x>0) { u32fact = u32fact *x; x--; } } }


Is unsigned int var valid in java?

No. Java uses no unsigned numbers.


What if you feed an int value and an unsigned int value?

Feed? What do you mean by that


What is the type modifier?

A type modifier changes the default variable type to the other possible type. An int is signed by default and may be made unsigned int a; unsigned int b;


What if -1 is assigned to a unsigned variable in C plus plus?

If you assign -1 to a unsigned variable it will contain the biggest number its able to hold. For example if you assign -1 to a unsigned int it will be 4294967295 as its the biggest number a unsigned int can hold.