Learning Java with Aditya Tandon Sir: Negative Numbers & Floating-Point

Day 4 of Learning Java : Today I started my journey into Java programming which is taught by Aditya Tandon Sir. Here are the key concepts I learned today: How Java Stores Negative And Floating Numbers? 1. Storing Negative Integers: Two’s Complement -- >Java doesn't just stick a "minus sign" in front of a number. Instead, it uses a system called Two’s Complement. In a standard 32-bit int, the most significant bit is the sign bit. • 0: Positive •1: Negative ∆ How to calculate Two's Complement: -->To store a negative number (like -5), Java follows these steps: 1.Start with the positive binary: 00000101 (for 5). 2.Invert the bits (One's Complement): 11111010. 3.Add 1: 11111011. 2. Storing Floating-Point Numbers: IEEE For float and double, Java follows the IEEE 754 standard. It stores numbers in a way similar to scientific notation but in binary. ∆ A 32-bit float is broken into three parts: 1.Sign Bit (1 bit): 0 for positive, 1 for negative. 2.Exponent (8 bits): Determines how large or small the number is (the "scale"). 3.Mantissa/Fraction (23 bits): Stores the actual digits of the number. This is just the beginning. Excited to continue this journey Special thanks to Rohit Negi bhaiya & Aditya Tandon Sir. #Day4 #Java #Coding #Learning #Consistency

  • No alternative text description for this image

To view or add a comment, sign in

Explore content categories