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 


what is the negative of 80 ?

 
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: Wed May 05, 2010 3:58 am    Post subject: what is the negative of 80 ? Reply with quote

since
neg 0 = 0
neg 1 = ff
neg 7f = 81
then neg 80 = 80 ?
is it a positive value or negative value?

if 80 is negative value, then neg 80 should be a positive value, right?
but 80 = 80 , right?
Back to top
View user's profile Send private message
Pingo
Grandmaster Cheater
Reputation: 8

Joined: 12 Jul 2007
Posts: 571

PostPosted: Wed May 05, 2010 5:08 am    Post subject: Reply with quote

Dont write it as byte value, use 2byte or 4byte
2byte
neg 0x80 = 0xFF80
pos 0x80 = 0x0080

4byte
neg 0x80 = 0xFFFFFF80
pos 0x80 = 0x00000080

_________________
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Wed May 05, 2010 7:42 am    Post subject: Reply with quote

look up two's complement on the internet
Back to top
View user's profile Send private message
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Wed May 05, 2010 7:46 am    Post subject: Reply with quote

Why don't you test it out yourself..
Code:
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
  unsigned char c[] = { -0x00, -0x01, -0x7F, -0x80 };
  int i;
  for(i=0; i<sizeof(c); ++i)
    printf("%x ", c[i]);
  return EXIT_SUCCESS;
}
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Wed May 05, 2010 7:51 am    Post subject: Reply with quote

Another easy way is to open up OllyDbg and double-click register values and play around with those since they have the representation in hex/binary/signed/unsigned.
Back to top
View user's profile Send private message
kot1990
Expert Cheater
Reputation: 1

Joined: 06 Sep 2009
Posts: 131
Location: Greece

PostPosted: Wed May 05, 2010 4:43 pm    Post subject: Reply with quote

if you talk about 1 byte then only the unsigned byte has a positive value 0x80 <-- which is +128 in decimal, unsigned byte is 0x00 - 0xFF equivalent 0-255 in decimal, but there are no negative values.

Now if you talk about signed byte, the number +128 in decimal does not fit in 1 byte because the signed byte is as follows

positives 0x00 - 0x7F ->> decimal 0 - +127 <-- +127 is the max positive that you can represent with 1 byte.

negatives 0x80 - 0xFF ->> decimal -128 - -1 (-128 is 0x80 and -1 is 0xFF)

So as you understand you'll need a second byte Smile
which can handle 65535 different values.

So with 2 bytes -1 is 0xFFFF . So if 0x80 is +128 (unsigned) and 0xFFFF is -1 then you should go backwards and do 0xFFFF - 0x80 +1 (+1 because -1 -128 = -129) wich is 0xFF80 Smile. I hope you'' figure it out time-time/.

EDIT: if you use the calculator and select WORD wich is 2 bytes, and type FF80 it will show the positive value because WORD is unsigned.
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