# Tag Info

Accepted

### Why is 2s complement of 000 equal to 111, but 9s complement of 000 is not 888?

You are very confused due what is simply poor terminology, to be honest. Both your statements 2 and 3 are false due to the same misunderstanding. For each base $b$ there are two mainstream variants of ...
• 13.8k

### The math behind converting from any base to any base without going through base 10?

This is a refactoring (Python 3) of Andrej's code. While in Andrej's code numbers are represented through a list of digits (scalars), in the following code numbers are represented through a list of ...
• 231

### Why is 2s complement of 000 equal to 111, but 9s complement of 000 is not 888?

The two's complement of 000 is 000. It is formed by complementing all bits and adding 1 to the result. The one's complement of 000 is indeed 111, but it is not used in computing. The ten's complement ...
• 278k

### Why aren't numbers stored this way?

In a floating point, by definition, the point floats. What you're proposing is fixed point (which is occasionally used in practice). A normal IEEE 754 64-bit double precision can store values in the ...
• 13.4k

### Is there any practical trick to mentally count in Gray code?

I have a solution that I just found looking at the patterns, and I checked the pattern up to decimal 31 or binary 11111 or Gray 10000, and it worked quite fine, and I am confident enough the answer ...
Accepted

### Imaginary numbers and negative zero

Yes, there is a usage for the negative imaginary zero. But first, I will say something about the negative zero in general. Why have a negative zero? First of all, the main reason to have a signed ...
• 8,323
Accepted

### Why does little endian apply to numbers and not to text strings?

The premise is wrong. Unicode encodings include UTF-16BE, UTF-16LE, UTF-32BE and UTF32-LE. Only UTF-8 has no Litte-Endian or Big-Endian variants. Fundamentally, Endian-ness is about the byte order of ...
• 905

### The math behind converting from any base to any base without going through base 10?

Fundamental operation of base convertion is the toDigits() operation of @AndrejBauer answer. However, to make it there is no need to create a number in the internal ...

### Is decimal number 8 represented as 3 bits or 4 bits in computer?

$b$ bits have a total of $2^b$ distinct bit-patterns. To store 8 distinct values, you need at least 3 bits. This does not tell you on its own how many bits are required to store the number 8, because ...
• 1,043

### Why aren't numbers stored this way?

The gravitational constant is about $6.67 \times 10^{-11} N m^2 kg^{-2}$. You would want a scheme that allows storing this number at the full known precision. Unfortunately, it is about 1 quarter of ...
• 31.4k

### Is there any practical trick to mentally count in Gray code?

The title of my masters thesis was Efficient Hardware Implementations of Gray Code Arithmetic. The goal was to find a way to, at the digital hardware level, perform arithmetic on Gray code directly ...

### Floating point normalised numbers in binary

Historically, floating point binary formats have varied from machine to machine. For example, some put the exponent on the left and the mantissa on the right, and some use sign and magnitude instead ...
• 131

### Why floating point representation uses a sign bit instead of 2's complement to indicate negative numbers

IEEE 754 uses sign/magnitude, not two's complement or one's complement. Two's complement has the disadvantage that the positive and negative range are not identical. If all bit patterns are valid, ...
• 31.4k

### Why can we write almost any nonzero 2-adic integer in the same form?

The pattern $x = (\alpha01^a10^b)_2$ is very easy to match. For example, the number $1=0^\infty1$ matches the pattern with $\alpha=0^\infty, a=b=0$. Try matching some other numbers yourself. The only ...
• 3,677
Accepted

### Repeated addition and comparisons of floating point numbers

The reason you are seeing these results are not due to the memory limits of your computer, but rather of the limits of the encoding of "floating point" numbers. Python uses 64 bit floats (aka double ...
• 113

"Floating point" means a representation in which the position of the fraction indicator (the "point") in a number is allowed to take on a range of values, allowing the fixed-length representation of ...
• 12.1k

### Data type implementation of 1.58 bits

They are using trinary values which have an information density of $\log_2 3 = 1.584963...$ bits per trinary digit. The effective implementation for computation in traditional compute devices is going ...
• 4,646

### Why floating point representation uses a sign bit instead of 2's complement to indicate negative numbers

Having signed zeros gives increased expressiveness that may be useful in numerical computations. The wikipedia page ‘Signed zero’ says: It is claimed that the inclusion of signed zero in IEEE 754 ...
• 190

### What does normalizing with hidden bit really mean?

Shorter Answer (As requested by greybird in the comments) : The gist of "normalizing" in scientific notation, is not to allow the same number to have ...
• 121

### Difference between ways to compare floating-point numbers

You are rightfully confused, because these answers mix up incompatible concepts into a right mess. If you want to know whether two floating point numbers are equal then you use the "==" operator, ...
• 31.4k

### Is there any practical trick to mentally count in Gray code?

Wikipedia describes a very simple algorithm for this task: To construct the binary-reflected Gray code iteratively, at step 0 start with the $\text{code}_0 = 0$, and at step $i > 0$ find the bit ...
• 164k

### Is there any practical trick to mentally count in Gray code?

Gray codes are hamilton cycles in hypercube graphs $Q_n$, which can be recursively constructed using Hamilton cycles in $Q_{n-1}$. Perhaps you can do these computations by hand for small n and see if ...
• 389
Accepted

### Confusion in 2's complement of 00000000

You have 00000000 as the number, it implies how many bits are used. The 1 at the front comes from carry bit, but two complements does not extend number of bits used, so the answer is 00000000, as the ...
• 9,495
Accepted

### Why can we write almost any nonzero 2-adic integer in the same form?

Addressing first the explicitly asked questions: Two things bug me about this: 1. "is almost any" is imprecise, The meaning of “almost any” here is given in the next sentence, in the same ...
• 289

### Overflow rule in two's complement arithmetic

Yes, if we are talking about integers. In two's complement representation with length $n$ you can only represent the integers between $-2^{n-1}$ and $2^{n-1} - 1$ (both bounds inclusive). Thus, the ...
• 5,027

### Why does little endian apply to numbers and not to text strings?

You certainly could do it that way. It's an arbitrary decision. You could store characters in ascending order, or in descending order.
• 164k

### What is the equivalent of the integers symbol Z for n bit only integers?

For bounded sets, the usual convention is to use interval notation. Specifically, $[a,b]$ means "real numbers between $a$ and $b$, inclusive", while $[a\mathinner{\ldotp \ldotp}b]$ means "integers ...
• 7,176
Representing a rational number as ${a \over b} \times c^d$ where $a,b,c,d$ are integers can represent all three classes of numbers you mentioned efficiently. You can do standard operations on numbers ...