Raised This Month: $51 Target: $400
 12% 

What is ~0 value?


Post New Thread Reply   
 
Thread Tools Display Modes
Natsheh
Veteran Member
Join Date: Sep 2012
Old 02-10-2021 , 11:21   Re: What is ~0 value?
Reply With Quote #11

Quote:
Originally Posted by fysiks View Post
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 View Post
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 
szBits40 ];
    new 
iStringPos charsmaxszBits );
    
    
szBitsiStringPos ] = EOS;
    
    for ( new 
31 >= i-- )
    {
        
szBitscharsmaxszBits ) - iStringPos-- ] = iVal & ( << ) ? '1' '0';
        
        if ( !( 
iStringPos ) && ( iStringPos ) )
            
szBitscharsmaxszBits ) - 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?
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 02-10-2021 at 11:24.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-10-2021 , 11:47   Re: What is ~0 value?
Reply With Quote #12

I am currently on a relatively old 1.9 build
__________________
Bugsy is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 02-10-2021 , 14:11   Re: What is ~0 value?
Reply With Quote #13

Quote:
Originally Posted by Bugsy View Post
I am currently on a relatively old 1.9 build
YUP it works fine for some reason when i tested it was bugging because some other bug thats why
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-10-2021 , 22:26   Re: What is ~0 value?
Reply With Quote #14

Quote:
Originally Posted by Natsheh View Post
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?
With two's complement, the most-significant (left most) bit does happen to be a 1 but you can't change the sign of a number by just changing that bit.
__________________
fysiks is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 19:38.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode