Java Integer Storage: Binary, Octal, Hexadecimal Explained

Today I explored how different number systems — Decimal, Octal, and Hexadecimal — are converted into Binary and how they are actually stored in memory. Key Takeaways: 🔹 All integer types in Java (byte, short, int, long) are stored in Base 2 (Binary format) 🔹 Positive numbers → MSB (Most Significant Bit) = 0 🔹 Negative numbers → Stored using 2’s Complement (MSB = 1) Examples I practiced: byte a = 24 → Stored as binary byte a = -24 → Converted using 2’s complement int a = 045 → Octal (prefix 0) → Binary int a = 0x45 → Hexadecimal (prefix 0x) → Binary Concept Clarity: ✔ Octal → Each digit = 3 bits ✔ Hexadecimal → Each digit = 4 bits ✔ No prefix → Decimal ✔ 0b → Binary (Java 7+) Bonus Learning: Real numbers (float, double) use IEEE 754 format Characters in Java use Unicode encoding Understanding how data is stored at the binary level really changes the way I see programming! #Java #Programming #Coding #JavaLearning #DeveloperJourney #100DaysOfCode #ComputerScience #LearningInPublic

  • table

To view or add a comment, sign in

Explore content categories