Skip to content

Commit

Permalink
feat: Add other binary topics
Browse files Browse the repository at this point in the history
  • Loading branch information
apmaros committed Sep 2, 2024
1 parent 88a3933 commit 9cf5023
Showing 1 changed file with 28 additions and 11 deletions.
39 changes: 28 additions & 11 deletions _web/2024-09-01-data-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,35 @@ categories: types

# Java Types

| Type | Bit Width | Description |
|---------|-----------|-------------------------------------------------------------------|
| byte | 8 | An 8-bit signed two's complement integer - -127 - 127 (inclusive) |
| short | 16 | |
| int | 32 | |
| long | 64 | |
| float | 32 | |
| double | 64 | |
| boolean | n/a | |
| char | 16 | |
Java numbers have signed two's complements representation. Exception is int and long as they both also support unsigned integers (since Java SE 2).

| Type | Bits |
|:--------|:-----|
| byte | 8 |
| short | 16 |
| int | 32 |
| long | 64 |
| float | 32 |
| double | 64 |
| boolean | n/a |
| char | 16 |


# Binary Number

A binary number is a number expressed in a base-2 notation. Only `1` and `0` symbols are used to encode the number.

# Two's complement Number Representation

Two complement number representation is achieved by applying **NOT** operation (negating) a binary number. Most systems use Two's complement number representation as it allows to unify addition and subtraction.

# Signed and Unsigned Numbers

Unsigned binary numbers are positive numbers. For example a 8-Bit unsigned number have range of 0 - 2^8-1 (255). Signed binary numbers require arithmetic sign. The most significant bit represent the sign bit. The rest of the numbers represent the value.


# References

- [1] Primitive Data Types (Java) - <https://docs.oracle.com/javase%2Ftutorial%2F/java/nutsandbolts/datatypes.html> - 2024-09-01
- [1] Primitive Data Types (Java) - <https://docs.oracle.com/javase%2Ftutorial%2F/java/nutsandbolts/datatypes.html> - 2024-09-01
- [2] Binary Number - <https://en.wikipedia.org/wiki/Binary_number> - 2024-09-02
- [3] Two's Complement - <https://en.wikipedia.org/wiki/Two's_complement> - 2024-09-02

0 comments on commit 9cf5023

Please sign in to comment.