Study guides

☆☆

Q: What is the effect of shifting an unsigned number in a register two bits to the right?

Write your answer...

Submit

Still have questions?

Related questions

The second.

unsigned __int64 factorial(unsigned __int64 number) { unsigned __int64 factorial=1; while(number) factorial*=number--; return(factorial); }

a signed number is one that can be negative (have a sign) whereas an unsigned number will only be positive. due to less information, you can double the largest number storable in a signed integer to get the data available in an unsigned integer. However, PHP doesn't have unsigned integers, they're all signed.

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.

#include<iostream> #include<vector> unsigned count_digits (unsigned num, const unsigned base=10) { unsigned count=1; while (num/=base) ++count; return count; } class number { std::vector<unsigned> value; unsigned base; public: number (const unsigned _value, const unsigned _base=10): value {}, base {_base} { *this = _value; } number& operator= (const unsigned _value); operator unsigned () const; bool is_narcissistic () const; }; number& number::operator= (unsigned _value) { unsigned count = count_digits (_value, base); value.resize (count); while (count) { value[value.size()-count--] = _value%base; _value/=base; } return *this; } number::operator unsigned () const { unsigned num = 0; for (unsigned index=0; index<value.size(); ++index) num += value[index]*static_cast<unsigned>(std::pow (base, index)); return num; } bool number::is_narcissistic () const { unsigned num = 0; for (unsigned index=0; index<value.size(); ++index) num += static_cast<unsigned>(std::pow (value[index], value.size())); return num == static_cast<unsigned> (*this); } unsigned main() { const unsigned min=1; const unsigned max=100; std::cout << "Narcissistic numbers in the range " << min << " through " << max << ":\n\t"; for (unsigned n=min; n<=max; ++n) if (number(n).is_narcissistic()) std::cout << n << ' '; std::cout << '\n' << std::endl; }

#include<iostream> unsigned sum_of_digits(unsigned num) { unsigned sum = 0; do { sum += num%10; } while (num/=10); return sum; } int main() { unsigned number = 12345; unsigned sum = sum_of_digits (number); std::cout << "Sum of digits in " << number << " is " << sum << std::endl; }

Reverse the digits then test to see if the new number is the same as the original number. If it is, the number is a palindrome, otherwise it is not. To reverse an unsigned integer (any base, default is 10): unsigned rev (unsigned num, unsigned base=10) { unsigned r=0; while (num) { r*=base; r+=num%base; num/=base; } return r; }

65536

unsigned lowest_digit (unsigned num) { unsigned lowest = 9; // lowest digit until proven otherwise... while (num) { unsigned digit = num%10; // extract least-significant digit if (digit

it is decimal unsigned number system...

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

32767 signed, 65535 unsigned.

People also asked