# Tag Info

32

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 the 'complement', the radix complement and the diminished radix complement. The two most common bases in computer science are base $2$ and base $10$. ...

30

While you will need fewer 80-based numbers than 2-based numbers (bits) to encode the same file, the only way to store these 80-based numbers on a computer is to encode them as bits. So you do not gain anything. In fact you actually lose space, since 80 is not a power of 2: You will need 7 bits for each 80-based number, but in these 7 bits you could instead ...

21

There is no way to represent all real numbers without errors if each number is to have a finite representation. There are uncountably many real numbers but only countably many finite strings of 1's and 0's that you could use to represent them with.

20

It all depends what you want to do. For example, what you show is a great way of representing rational numbers. But it still can't represent something like $\pi$ or $e$ perfectly. In fact, many languages such as Haskell and Scheme have built in support for rational numbers, storing them in the form $\frac{a}{b}$ where $a,b$ are integers. The main reason ...

12

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 of 000 is 000. It is formed by complementing all digits and adding 1 to the result. The nine's complement of 000 is indeed 999. I suggest thoroughly reading the ...

10

There are several ways to interpret the question. What I think you might be asking is that you have a sequence of $n$ letters in an alphabet $\Sigma$ where $\left| \Sigma \right| = 80$. You want to store this in as few as possible bits. We will assume that the letters in the alphabet are uniformly distributed. The information-theoretic amount of space ...

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 arbitrary symbols taken from a custom string: def v2r(n, base): # value to representation """Convert a positive number to its digit ...

7

This is best explained in the base 10 equivalent: scientific notation In scientific notation you have a mantissa and a exponent such that the value is $\mathrm{mantissa} \cdot 10^{\mathrm{exponent}}$. In a computer floating point the mantissa is always the same size of significant digits (a double precision has around 16 digits) and the exponent is bounded....

7

There are many effective Rational Number implementations but one that has been proposed many times and can even handle some irrationals quite well is Continued Fractions. Quote from Continued Fractions by Darren C. Collins: Theorem 5-1. - The continued fraction expression of a real number is finite if and only if the real number is rational. Quote ...

6

Your idea does not work because a number represented in base $b$ with mantissa $m$ and exponent $e$ is the rational number $b \cdot m^{-e}$, thus your representation works precisely for rational numbers and no others. You cannot represent $\sqrt{2}$ for instance. There is a whole branch of computable mathematics which deals with exact real arithmetic. Many ...

6

If you drop the leading zeroes then $3,5,9,17$ and so on will all have the same representation. Don't forget that the number being represented need not be an integer.

6

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 range from $-10^{308}$ to $10^{308}$. This is a much larger range than your system can store given 64 bits (you would need nearly 800 bits to achieve the same). ...

5

Generally speaking, normalized means "put in scientific notation." That just means, the mantissa should never start with 0, and should be less than the base. In binary that means the mantissa must be "1". Since the mantissa of a normalized binary floating point number is always 1, we don't need to store the 1. The first mantissa bit is hidden in the ...

5

Just converting the comment into a short answer: $7 = \text{int}(\log_{2} 236)$. Generally, $p = \text{int}(\log_{B}V)$. As other people pointed out, this algorithm is needlessly complicated and not practical; it is not easy to calculate $\log_B V$ for large $V$ by pencil and paper. Instead, use the other algorithm which is also mentioned in the article ...

5

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 zero for floating points is that floating points have only limited precision and we often want to distinguish the following cases of a real number $x$, ...

4

There are a number of "exact real" suggestions in the comments (e.g. continued fractions, linear fractional transformations, etc). The typical catch is that while you can compute answers to a formula, equality is often undecidable. However, if you're just interested in algebraic numbers, then you're in luck: The theory of real closed fields is complete, o-...

4

I don't know what calculators actually use, but there are definitely better algorithms than your brute force search. There are several notions of “best approximation” of a real number by a rational. Depending on how you rate the benefit of a good approximation compared to the cost of a large denominator, you get different notions. One of these is the best ...

4

Continued fractions are an efficient way to enumerate rational numbers that are a good approximation of your number $x$. In particular, given a real number $x$, you can generate a sequence of truncated continued fractions $a_i/b_i$, where each rational number $a_i/b_i$ is a better approximation to $x$ than any other fraction whose denominator is $\le b_i$. ...

4

It's not true that when all components of the exponent are 0 then the number must represent 0. A (normalized) floating point number is composed of two parts: sign, exponent, and mantissa. The value of the number is $$\text{sign} \times 1.\text{mantissa} \times 2^{\text{exponent} + \text{base}},$$ where the sign is $\pm 1$ (though encoded as a bit), and $\... 4 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 multi-byte words, and you're thinking of text encodings which use a single byte per character (i.e. ASCII). There's no order to a single byte. 3 The fractional part is in binary:$(0.01010101\ldots)_2 = (0.333333\ldots)_{10}$. To convince yourself of this, try multiplying the binary$0.0101010101\ldots$by$3$: you will get$0.111111\ldots = 1$. In a similar way, the decimal$0.0101010101\ldots$equals$1/99$. The mantissa (fractional part) in fact has an implicit$1.$in front, so it actually ... 3 The second exponent is FF, which signals NaN according to Wikipedia, and so the highest exponent is only FE. This is verified by the following C code snippet: unsigned int i = 0x7FFFFFFF; float f = *(float*)&i; If you print f you get nan. 3 If you have a number (eg. 123456789⏨) as text you can write it in a different base (such as 21i3v9 in base 36), so you compress it written as text (from 9 characters to 6). If you go further you end up storing it in binary (4 bytes¹). Now, this works because you started with a reduced set [0-9] and moved to a bigger one [0-9a-z] and many bits of data were ... 3 The reason we get a larger range is denormalized numbers. Generally speaking, floating point numbers have three physical parts: sign (1 bit), mantissa$M$and exponent$e$. Most of the time we think of the number as$\operatorname{sgn} \times 1.M \times 2^{e-e_0}$, where$e_0 = 2^{|e|}-1$(e.g. for single precision, it's 127, since the exponent is allotted ... 3 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, then you have numbers x where you can't easily calculate -x. That's bad. The alternative is that there are invalid bit patterns, which is also bad. In IEEE 754 ... 3 A brute force solution is to trace the line ay=bx in integer coordinates from the origin to (a,b). Any pair with a smaller number of bits will be along that line segment. This method allows finding either the minimum distance or the smallest (x,y) within the error bounds. It requires o(a+b) steps, and there's plenty of redundancy possible, since eg both (x,... 3 I'm assuming you're talking about IEEE754. Unless I'm missing something, your book is wrong. Every number in IEEE754 is represented as normalized (starting with a 1), unless your number is subnormal. A number is only subnormal if the mantissa is minimal (all zeroes). Since the first bit is the sign bit,$10\$ could be the start of a subnormal number. For ...

3

In answer to the OP, and looking around Tony Piper I found this page: http://www.teach-ict.com/as_as_computing/ocr/H447/F453/3_3_4/floating_point/miniweb/pg10.htm Essentially, a non-normalised 8 bit floating point is represented like: Sign Integer Fraction Exponent 0 111 .0 010 The largest number this can represent is 111.1 with a 111 ...

3

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 of twos complement. It wasn’t until 1985 that the Institute of Electrical and Electronics Engineers agreed on the standard format used in most of today’s ...

3

A good start is to expand the hex representation into binary like how you did it. 0000 1100 0000 0000 0000 0000 0000 0000 Then parse the word: the left-most bit is the sign bit the next 8 bits represent the biased-exponent the last bits represent the fractional part with the "hidden one" 0 | 00011000 | 00000000000000000000000 Then, follow: s ...

Only top voted, non community-wiki answers of a minimum length are eligible