Skip to main content
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....
gnasher729's user avatar
  • 31.5k
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$, ...
Yves Daoust's user avatar
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 ...
Emil Jeřábek's user avatar
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 ...
gnasher729's user avatar
  • 31.5k
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 ...
Peter Cordes's user avatar
  • 1,065
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 ...
bbv's user avatar
  • 191
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 ...
hobbs's user avatar
  • 429
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 ...
David Hammen's user avatar
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 ...
Gilles 'SO- stop being evil''s user avatar
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 ...
Emil Jeřábek's user avatar
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 <...
Toothpick Anemone's user avatar
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 ...
njuffa's user avatar
  • 530
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 ...
quicksort's user avatar
  • 4,272
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 ...
Discrete lizard's user avatar
  • 8,322
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 ...
gnasher729's user avatar
  • 31.5k
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 ...
gnasher729's user avatar
  • 31.5k
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 ...
Пафнутий Чебышев's user avatar
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^...
Yashas's user avatar
  • 275
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.'s user avatar
  • 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 ...
Nayuki's user avatar
  • 881
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....
André Souza Lemos's user avatar
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 ...
gnasher729's user avatar
  • 31.5k
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 ...
Yuval Filmus's user avatar
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, ...
gnasher729's user avatar
  • 31.5k
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.'s user avatar
  • 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.
David Richerby's user avatar
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, ...
Grabul's user avatar
  • 1,870
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 ...
Tobias's user avatar
  • 325
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 ...
gnasher729's user avatar
  • 31.5k
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 ...
gnasher729's user avatar
  • 31.5k

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