ALL
JavaScript's Two Zeros
JavaScript has two zeros: -0 and +0. This post explains why that is and where it matters in practice.The signed zeroNumbers always need to be encoded to be stored digitally. Why do some encodings have two zeros? As an example, let’s look at encoding integers as 4-digit binary numbers, via the sign-and-magnitude method. There, one uses one bit for the sign (0 if positive, 1 if negative) and the remaining bits for the magnitude (absolute value). Therefore, -2 and +2 are encoded as follows. Binary 1010 is decimal -2 Binary 0010 is decimal +2 Naturally, that means that there will be ...
3,870 0 JAVASCRIPT ZEROS