A C++ function to figure out whether one unsigned integer is bigger than another -


I was wondering if you can help me with a function I am trying to decide Whether an unsigned integer is larger than one b

  # include & lt; Limits.h & gt; # Include & lt; Iostream & gt; Bool is_bigger (unsigned int one, unsigned int b) // returns are bigger than one b; Incorrectly incorrectly (for I int = 0, j = sizeof (unsigned int) * CHAR_BIT; i   

For some reason this program outputs output to true maybe something is wrong about my argument? Does anyone know about a library that I can download that can see the function which is bigger than one integer second?

Despite the fact that you can only operator & gt; with an unsigned integer, which means a & gt;

EDIT: There is still something wrong with my version, see.

If I had to write a loop that repeats it at least one of the integer pieces of an integer, I want to move the better right as if the one you want to see is the least important Moved the result with a single 1 after it is transferred to the bit:

 for  (int i = sizeof (unsigned int) * CHAR_BIT - 1 ; I> ==; --i) {int b1 = (a & gt; & gt; i) & amp; 1; Int B2 = (B & gt; & gt; I) & amp; 1; If (B2 and B1) false return; } Back true;   

Note: It's better to write sizeof (unsigned int) instead of size because you can change the type of the bus a and b are very useful in signature without worrying about the function body, if you template it a function.

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -