32
votes
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
votes
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 ...
12
votes
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 ...
6
votes
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 ...
6
votes
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 ...
6
votes
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 ...
6
votes
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 ...
5
votes
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 ...
5
votes
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 ...
3
votes
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 ...
3
votes
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 ...
3
votes
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 ...
3
votes
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, ...
3
votes
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
votes
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 ...
3
votes
facts about ieee 754
"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 ...
3
votes
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 ...
2
votes
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 ...
2
votes
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 ...
2
votes
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, ...
2
votes
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 ...
D.W.♦
- 164k
2
votes
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 ...
2
votes
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 ...
2
votes
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 ...
2
votes
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 ...
2
votes
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.
D.W.♦
- 164k
2
votes
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 ...
2
votes
Space-efficient representation of potentially very large arbitrary-precision rationals?
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 ...
D.W.♦
- 164k
2
votes
How much can we trust mathematical software when working with large numbers, and how much memory it needs to work with these numbers?
Question a):
Here is the output from python console.
...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
number-formats × 90floating-point × 42
arithmetic × 13
binary × 12
algorithms × 10
computer-architecture × 9
numeral-representations × 6
integers × 4
encoding-scheme × 4
base-conversion × 4
number-theory × 3
numerical-analysis × 3
real-numbers × 3
numerical-algorithms × 2
normal-forms × 2
data-structures × 1
machine-learning × 1
terminology × 1
combinatorics × 1
search-algorithms × 1
binary-trees × 1
strings × 1
efficiency × 1
randomness × 1
data-compression × 1