5 ms·
> Double precision usually refers to 64-bit floating point, like you say. Is it? Doesn't `double` in c refers to a 32bit value? EDIT: So, it seems I've not d
by jimktrains2 6y ago
> Double precision usually refers to 64-bit floating point, like you say.
Is it? Doesn't `double` in c refers to a 32bit value?
EDIT:
So, it seems I've not dealt with this in much too long and am misremembering and therefor wrong.
#include <stdio.h>
int main() {
printf("sizeof(float) = %d\n", sizeof(float));
printf("sizeof(double) = %d\n", sizeof(double));
return 0;
}
yields
sizeof(float) = 4
sizeof(double) = 8
on an Intel(R) Core(TM) i5-6200U (more-or-less a run-of-the-mill-not-that-mill 64-bit x86-family core. I don't have a 32-bit processor handy to test, but I don't believe it'd change the results.
- froydnj 6y agoNot usually; `float` is 32 bits and `double` is 64 bits on virtually every common platform (maybe not on some DSP chips or certain embedded chips?). But the C++ standard (and probably the C one) only requires that `double` have at least as much precision as a `float`, so it's conceivable you could have a C++ implementation with 32-bit `float` and `double` or 16-bit `float` and 32-bit `double.
- Something1234 6y agofloat == 32 bits, double == 64 bits.
- coliveira 6y agoC never required that the size of int or double be the same across compilers. Even in the same machine they can have different sizes.
- zokier 6y ago"F.2 Types The C floating types match the IEC 60559 formats as follows: — The float type matches the IEC 60559 single format. — The double type matches the IEC 60559 double format. — The long double type matches an IEC 60559 extended format, else a non-IEC 60559 extended format, else the IEC 60559 double format. Any non-IEC 60559 extended format used for the long double type shall have more precision than IEC 60559 double and at least the range of IEC 60559 double. Recommended practice The long double type should match an IEC 60559 extended format." ISO/IEC 9899:1999, Annex F