If double can store larger value than long long, then why everyone rarely used double?
# | User | Rating |
---|---|---|
1 | tourist | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
# | User | Contrib. |
---|---|---|
1 | cry | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 161 |
5 | djm03178 | 158 |
6 | -is-this-fft- | 157 |
7 | adamant | 155 |
8 | awoo | 154 |
8 | Dominater069 | 154 |
10 | luogu_official | 151 |
If double can store larger value than long long, then why everyone rarely used double?
Name |
---|
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.