Quote:
Originally Posted by fysiks
|
Thanks I understood the technique but I've heard once they define the negative numbers by setting the last bit to 1 is that even correct?
Quote:
Originally Posted by Bugsy
Read up on bits, there are tutorials all over the net, they are not specific to AMX-X.
What didn't work in the code I posted? It worked for me
PHP Code:
public test() { new iVal = ~0; new szBits[ 40 ]; new iStringPos = charsmax( szBits ); szBits[ iStringPos ] = EOS; for ( new i = 31 ; i >= 0 ; i-- ) { szBits[ charsmax( szBits ) - iStringPos-- ] = iVal & ( 1 << i ) ? '1' : '0'; if ( !( iStringPos % 5 ) && ( iStringPos > 0 ) ) szBits[ charsmax( szBits ) - iStringPos-- ] = ' '; } server_print( "Value = %d" , iVal ); server_print( "Bits = %s" , szBits ); }
Output:
Code:
Value = -1
Bits = 1111 1111 1111 1111 1111 1111 1111 1111
|
What compiler did you use for the test?
__________________