JavaChallenge41

Govinda Raj
wolfie/JavaChallenge
2 min readOct 8, 2021

--

Try to solve the challenge by yourself first.

Looks pretty simple, but did you know it already?

The answer is —

Yes, it’s not Already knew . Not only this, but the following are also true —

But how? How 0, 0.0, -0.0,-0, 0.0D, 0.0f are stored in memory?

If the above mentioned are true that means all are pointing to the same value which means 0=-0=0.0=-0.0=0.0D=0.0f.

Let’s find out the answer to how?

We know that decimal values are stored in binary format in memory, so let’s find out the binary values of 0 and -0 considering the 8bits machine.

Reference — https://en.wikipedia.org/wiki/Two's_complement and Binary Number System

Let’s find out how to write a floating-point number in binary —

Reference — http://cstl-csm.semo.edu/xzhang/Class%20Folder/CS280/Workbook_HTML/FLOATING_tut.htm

You let me know in the comment section how 0.0=-0.0.

Thanks a lot for your time. LinkedIn | Twitter

--

--

Govinda Raj
wolfie/JavaChallenge

Senior Software Developer. Tech Enthusiast and love coding. My portfolio: https://govinda-raj.github.io/