20
votes
Accepted
Inequality caused by float inaccuracy
In typical floating point implementations, the result of a single operation is produced as if the operation was performed with infinite precision, and then rounded to the nearest floating-point number....
15
votes
Why do computers use binary numbers in IEEE754 fraction instead of BCD or DPD?
the binary representation is the most efficient. BCD wastes 17% of the bits.
binary arithmetic is the simplest to implement in hardware.
"the smallest difference between numbers is $0.015625$, ...
14
votes
Accepted
Big Transition of Binary Counting in perspective of IEEE754 floating point
Incrementing 011111110111...111 to 011111111000...000 changes the float32 value from $\approx3{.}4\times10^{38}$ to +infinity, which is an infinite difference. Likewise with negative sign. (There are ...
11
votes
Why do computers use binary numbers in IEEE754 fraction instead of BCD or DPD?
Quite simply, your assertion that BCD gives more precision is wrong.
For example, 20 bits = 5 BCD numbers = 5 digits, while 20 binary digits = 0 to 1,048,575 = more than 6 digits. BCD is very ...
10
votes
Is significand same as mantissa in IEEE754?
They're used as synonyms in the context of floating point math, but "mantissa" is less correct mathematically.
It's fewer syllables, easier to type, and starts with a different letter than ...
9
votes
Understanding denormalized numbers in floating point representation
Although, the question is a bit old, but it may help people coming here for similar question.
A vital detail was missed out in the article that you referred to and it is that the standard chose to ...
9
votes
Big Transition of Binary Counting in perspective of IEEE754 floating point
For all of the "normal" finite floating point numbers (those between 1.18*10^-38 and 3.40*10^38, or between -1.18*10^-38 and -3.40*10^38, for IEEE-754 binary32 floats), the behavior is very ...
8
votes
Accepted
Number of FLOPs (floating point operations) for exponentiation
Assuming multiplication between two numbers use one FLOP, the number of operations for $x^n$ will be $n-1$. However, is there a faster way to do this ...
There most certainly is a faster way to do ...
8
votes
Accepted
Is significand same as mantissa in IEEE754?
In base 2, the significand is a number of the form $1.b_1b_2\ldots$ where the $b_i$'s are base 2 digits. The mantissa is the digits $b_1b_2\ldots$.
More generally, in base $n$, the normalized ...
8
votes
Why do computers use binary numbers in IEEE754 fraction instead of BCD or DPD?
Why would anyone want to use decimal?
The other answers have explained the many advantages of binary over decimal floating point. But what are the possible advantages of decimal over binary?
There is ...
7
votes
Accepted
Floating point arithmetic
Firstly, you need to decide if the floating point numbers you are working with are "normalized" or not.
Think about how binary numbers are represented in scientific notation.
Consider the number <...
6
votes
Accepted
Simple algorithm for IEEE-754 division on 8-bit CPU?
When using properly-rounded higher-precision floating-point arithmetic to compute operations in lower-precision arithmetic, there is the potential issue of double rounding: The result is first rounded ...
6
votes
Why do floating point values have infinity?
Because sometimes there just isn't an exponent high enough.
First of all, there is no way to effectively represent all real numbers in a reasonable computational model: it is sufficient to observe ...
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
How does computer store non-repeating decimal very accurately?
It may be that sqr (sqrt (7)) is displayed as 7, but it isn't actually exactly equal to 7. That's something you need to check. What you see is not always what you get. It may be that sqr (sqrt (7)) is ...
6
votes
Number of FLOPs (floating point operations) for exponentiation
Using n-1 multiplications would be rather daft. For example, if n = 1024, you just square x ten times. Worst case is 2 * log_2 (n). You can look up Donald Knuth, Art of Computer Programming, for some ...
6
votes
Accepted
numerically stable log1pexp calculation
Let $0 < \varepsilon \lll 1$ be the relative error bound of the floating-point system—$2^{-53}$ in IEEE 754 binary64 arithmetic.
First, the naive formula ...
6
votes
fast and stable x * tanh(log1pexp(x)) computation
With some algebraic manipulation (as pointed out in @orlp's answer), we can deduce the following:
$$f(x) = x \tanh(\log(1+e^x)) \tag{1}$$
$$ = x\frac{(1+e^x)^2 - 1}{(1+e^x)^2 + 1} = x\frac{e^{2x} + 2e^...
6
votes
Why do computers use binary numbers in IEEE754 fraction instead of BCD or DPD?
See https://en.wikipedia.org/wiki/Binary-coded_decimal, "Its principal drawbacks are..." and the section labelled "Disadvantages", for a discussion of several disadvantages of BCD.
D.W.♦
- 164k
5
votes
Inequality caused by float inaccuracy
The binary floating point format supported by computers is essentially similar to decimal scientific notation used by humans.
A floating-point number consists of a sign, mantissa (fixed width), and ...
5
votes
Inequality caused by float inaccuracy
Java uses IEEE 754 binary floating point representation, which dedicates 23 binary digits to the mantissa, that is normalized to begin with the first significant digit (omitted, to save space).
$0....
5
votes
Is IEEE 754 float arithmetic associative, commutative, distributive, etc? Why?
The IEEE 754 standard defines exactly how floating-point arithmetic is performed. For many interesting theorems, you will need to examine the exact definition. For some less interesting ones, like a+b ...
5
votes
Number of FLOPs (floating point operations) for exponentiation
You can use the formula
$$ x^y = \exp (y \ln x). $$
If you want to use only multiplications, when $n$ is a natural number you can use repeated squaring, that uses $O(\log n)$ multiplications. For ...
4
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, ...
4
votes
Floating Point Systems - Rounding Error in Taylor series
Yes, that's exactly why: it's due to floating-point roundoff error, due to the alternating signs.
Suppose you have $x=10^{100}$ and $y=10^{100}-1$, and you ask your computer to subtract $x-y$. We ...
D.W.♦
- 164k
4
votes
Accepted
What factors influence machine epsilon?
The phrase "machine epsilon" is misleading. In reality, it doesn't depend on the machine at all, but on the floating-point data types that the programmer chooses to use.
4
votes
Accepted
Comparing floating-point numbers as integers
There are a few fine tricks in the IEEE P754 format, which allows the use of integer operations for comparisons, or for rounding... It is useful for hardware implementations, for CPUs without an FPU, ...
4
votes
Accepted
Is the exponent in floating point numbers signed or unsigned
This is mostly a matter of interpretation. For IEEE 754 floating point numbers (one of the most common implementations), an exponent bias is used:
In IEEE 754 floating point numbers, the exponent ...
4
votes
Accepted
Are IEEE floating point numbers intervals or point values?
That has been long established. Most IEEE 754 floating point numbers represent exactly one real number. The exceptions are +0 and -0, +Inf and -Inf, and NaN with special meanings. (Thanks for one ...
4
votes
How to Add IEEE 754 Floating Point Numbers
It is difficult, and there are lots of special cases to handle.
Step 1: Determine if any of the operands is an Infinity or a Not-A-Number. In this case, look up the IEEE 754 standard and determine ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
floating-point × 238number-formats × 42
arithmetic × 36
numerical-analysis × 27
numerical-algorithms × 26
algorithms × 18
computer-architecture × 18
binary × 15
rounding × 11
error-estimation × 10
integers × 8
real-numbers × 7
mathematical-programming × 6
numeral-representations × 5
sorting × 4
approximation × 4
performance × 4
neural-networks × 3
computational-geometry × 2
combinatorics × 2
compilers × 2
parallel-computing × 2
number-theory × 2
cpu × 2
notation × 2