Difference between revisions of "Help File:Unsigned values"

From Cheat Engine
Jump to navigation Jump to search
(Created page with '{| width="100%" border="0" cellspacing="0" cellpadding="2" bgcolor="#FFFCEA" | align="left" |<font face="Arial" color="#010101" class="Arial3"><b>(Un)Signed value(s)</b>…')
 
m
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
{| width="100%"  border="0"  cellspacing="0"  cellpadding="2"  bgcolor="#FFFCEA"
+
[[Category:Help]]
|  align="left" |<font face="Arial"  color="#010101"  class="Arial3"><b>(Un)Signed value(s)</b></font>
+
In computing, a value can be either signed or unsigned.  
|}<hr><font class="Arial1"><br>
+
'''Unsigned values''' can only represent zero and positive numbers, while '''signed values''' can represent both positive and negative numbers.
In short, a value can hold a negative value if it is a signed value.<br>
+
 
This is done by inverting all the bits. All 0's become 1's and 1's become 0's. Then the resulting value is
+
== How Negative Numbers Are Stored (Two's Complement) ==
incremented by 1.<br><br>
+
 
example:<br>
+
To store negative numbers, computers use a method called '''two's complement''':
&nbsp;&nbsp;&nbsp;&nbsp; 12 = 00001100<br>
+
* Start with the binary representation of the positive number.
invert = 11110011<br>
+
* Invert all the bits (change 0's to 1's and 1's to 0's).
&nbsp;&nbsp; -12 = 11110100 (notice that if this was an unsigned value this would be 244; because 256-12=244)<br></font>
+
* Add 1 to the result.
 +
 
 +
For example, to represent -12 in 8 bits:
 +
- 12 in binary: <code>00001100</code>
 +
- Invert bits: <code>11110011</code>
 +
- Add 1:        <code>11110100</code>
 +
 
 +
So, <code>11110100</code> is -12 as a signed value. 
 +
If interpreted as an unsigned value, <code>11110100</code> would be 244 (since 256 - 12 = 244).
 +
 
 +
== Why This Matters ==
 +
 
 +
* '''Unsigned values''' are useful when you know a value will never be negative (e.g., memory addresses, sizes, counters).
 +
* '''Signed values''' are needed when negative numbers are possible (e.g., temperatures, scores, offsets).
 +
 
 +
== Links ==
 +
* [[Cheat Engine:Help File|Help File]]
 +
* [[Help_File:Big_endian_4_byte|Back]]
 +
* [[Help_File:Found_address_list|Next]]

Latest revision as of 20:57, 11 July 2025

In computing, a value can be either signed or unsigned. Unsigned values can only represent zero and positive numbers, while signed values can represent both positive and negative numbers.

How Negative Numbers Are Stored (Two's Complement)[edit]

To store negative numbers, computers use a method called two's complement:

  • Start with the binary representation of the positive number.
  • Invert all the bits (change 0's to 1's and 1's to 0's).
  • Add 1 to the result.

For example, to represent -12 in 8 bits: - 12 in binary: 00001100 - Invert bits: 11110011 - Add 1: 11110100

So, 11110100 is -12 as a signed value. If interpreted as an unsigned value, 11110100 would be 244 (since 256 - 12 = 244).

Why This Matters[edit]

  • Unsigned values are useful when you know a value will never be negative (e.g., memory addresses, sizes, counters).
  • Signed values are needed when negative numbers are possible (e.g., temperatures, scores, offsets).

Links[edit]