Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


which one is larger? 80 or 7F ?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
supercharger
Advanced Cheater
Reputation: 0

Joined: 06 Aug 2009
Posts: 61

PostPosted: Thu Nov 12, 2009 4:18 pm    Post subject: which one is larger? 80 or 7F ? Reply with quote

seems like in some program, 80 to FF are smaller than 00, therefore they are smaller than 01 to 7F .
but 7F + 01 = 80 right ?
i am confused.
Back to top
View user's profile Send private message
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Thu Nov 12, 2009 4:28 pm    Post subject: Reply with quote

It means the number is signed.
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Thu Nov 12, 2009 4:50 pm    Post subject: Reply with quote

http://en.wikipedia.org/wiki/Two's_complement
Back to top
View user's profile Send private message
smartz993
I post too much
Reputation: 2

Joined: 20 Jun 2006
Posts: 2013
Location: USA

PostPosted: Thu Nov 12, 2009 7:41 pm    Post subject: Reply with quote

Slugsnack wrote:
http://en.wikipedia.org/wiki/Two's_complement



http://en.wikipedia.org/wiki/Twos_complement
Back to top
View user's profile Send private message
NoManchesPuto
I post too much
Reputation: 0

Joined: 24 Jan 2009
Posts: 2820

PostPosted: Thu Nov 12, 2009 7:44 pm    Post subject: Reply with quote

Isn't 7F 7x15? So it would be larger right?
_________________
Back to top
View user's profile Send private message
smartz993
I post too much
Reputation: 2

Joined: 20 Jun 2006
Posts: 2013
Location: USA

PostPosted: Thu Nov 12, 2009 7:53 pm    Post subject: Reply with quote

GOGOGOGOGOGOGOGOGOGOGOGO! wrote:
Isn't 7F 7x15? So it would be larger right?


No.

7F = 127.
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Thu Nov 12, 2009 7:53 pm    Post subject: Reply with quote

0x7F = ( 7 * 16^1 + F * 16^0 )d
( 112 + 15 )d
127d
Back to top
View user's profile Send private message
NoManchesPuto
I post too much
Reputation: 0

Joined: 24 Jan 2009
Posts: 2820

PostPosted: Thu Nov 12, 2009 8:06 pm    Post subject: Reply with quote

But I thought F was 15 in hexadecimal? o.O Some odd uh codes there lol...

Well sorry I couldn't help, I'm stilling learning hexes so ^^

_________________
Back to top
View user's profile Send private message
LolSalad
Grandmaster Cheater
Reputation: 1

Joined: 26 Aug 2007
Posts: 988
Location: Australia

PostPosted: Thu Nov 12, 2009 11:31 pm    Post subject: Reply with quote

GOGOGOGOGOGOGOGOGOGOGOGO! wrote:
But I thought F was 15 in hexadecimal? o.O Some odd uh codes there lol...

Well sorry I couldn't help, I'm stilling learning hexes so ^^


F in hexadecimal is 15 in decimal. 10 in hexadecimal is 16 in decimal.

I guess you could think of 7F as 7×16+15 and 80 as 8×16+0 which are 127 and 128 respectively.

_________________
Back to top
View user's profile Send private message MSN Messenger
kot1990
Expert Cheater
Reputation: 1

Joined: 06 Sep 2009
Posts: 131
Location: Greece

PostPosted: Sat Nov 14, 2009 7:08 pm    Post subject: Reply with quote

of course 0x80 is greater than 0x7F. In memory even if the variable is signed, negative numbers are in the range of 0x80 - 0xFF.
What changes is the way the program will display and handle the signed variable and make computations with other variables in the program.

Here's an example in C

Code:

    char var1 = 0x80; //This is signed; In memory it is 0x80
    printf(%d,var1); //The output is -128;
    BYTE var2 = 0x80; //This is unsigned; In memory it is again 0x80
    printf("%d",var2); //But the output is 128;
    printf("%d",var1 + var2); // 0x80 + 0x80  <- the output is 0;
    printf("%d",var2 + var2); // 0x80 + 0x80  <- the output is 256;


As you see in memory the values look the same, but the program knows the type of every variable and treats it in different ways. So it has to do with the data type, if it is signed or unsigned Wink
Back to top
View user's profile Send private message
mStorm
Expert Cheater
Reputation: 0

Joined: 21 Feb 2009
Posts: 107

PostPosted: Tue Nov 24, 2009 5:11 pm    Post subject: Reply with quote

Take an 8-bit (one byte) integer for instance:

(0xFF) = 1111 1111 = Unsigned: 128, Signed: -1

The first bit determines whether or not the number is positive or negative... 1 = negative, 0 = positive.

Since 1000 0000 = 0x80, anything from 0x80-0xFF is going to be a negative number if the variable is signed.

To get the decimal value from that you would invert the bits and add one, then that is your negative number.

1000 0000 =

invert:
0111 1111

add 1:
0111 1111
+0000 0001
=1000 0000
=128 * -1
= -128
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites