If double can store larger value than long long, then why everyone rarely used double?
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 3993 |
2 | jiangly | 3743 |
3 | orzdevinwang | 3707 |
4 | Radewoosh | 3627 |
5 | jqdai0815 | 3620 |
6 | Benq | 3564 |
7 | Kevin114514 | 3443 |
8 | ksun48 | 3434 |
9 | Rewinding | 3397 |
10 | Um_nik | 3396 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
9 | nor | 153 |
If double can store larger value than long long, then why everyone rarely used double?
Название |
---|
Because
double
can't accurately store integers whose absolute value exceeds $$$2^{53}$$$. Take a look at this:This will not print what you might expect. To avoid such situations,
double
should be avoided in favor oflong long
when an exact algorithm is needed and all input/output/intermediate variables can be represented as integers. Also, integer types tend to be significantly faster.This is not entirely true, double can store accurately integers over 2^53 as long as the integer can be represented with 53 bits multiplied by a power of two (within 11 bits). For example, 2^100 has only 1 bit and a power of two of 100 that can fit with 11 bits, so it can be stored without a loss of precision and can be tested for direct equality without abs(num1-num2)<epsilon trick.
I didn't say that all such integers can't be represented, the point is that some can't.
Downvote me, please, but choose one :)
"double can't accurately store integers whose absolute value exceeds 2^53"
"I didn't say that all such integers can't be represented"
Formally, your first statement states that if an integer is above 2^53, it can't be represented correctly, so any such integer being represented correctly contradicts your statement, so the "all" is implied here.
If you can't accurately hit a target that doesn't mean that you will never hit it. The negation of accurate is not "always misses" but "does not always hit" — look up negation of logic quantifiers.
accuracy (n) — the quality or state of being correct or precise.
not accurate — not being correct or precise, NOT low % of being correct or precise :)
I give up, check back in a year
Appreciated, thanks, you gave hope to all the blues :)
That's where you're wrong. Let accuracy(n) be $$$A$$$ and the quality or state of being correct be $$$C$$$. Then $$$A \rightarrow C$$$ $$$\equiv$$$ $$$\neg C \rightarrow \neg A$$$, but it is not the same as $$$\neg A \rightarrow \neg C$$$.
That is, accuracy implies it is correct, and not correct implies that is is not accurate, but not accurate does not imply it is not correct.
It may be correct or may not be, but it is in no way a guarentee.
You are mistaking definition (iff) with implication.
The thing is it is not a bi-implication(iff), but an implication. If it is correct, it in no way means it is accurate. Maybe it was correct with very low probability on that experiment, and thus has low accuracy, ie not accurate.
So in your logic if something is not white, it may or may not be white :D
I'm giving up now too, back in a year.