General statistics
List of Youtube channels
Youtube commenter search
Distinguished comments
About
Lawrence D’Oliveiro
Low Level
comments
Comments by "Lawrence D’Oliveiro" (@lawrencedoliveiro9104) on "coding in c until I go completely insane" video.
So has Python. And Python isn’t limited to 18 decimal digits.
22
@marcossidoruk8033 Microsoft Windows user?
3
@marcossidoruk8033 Sounds like a typical Microsoft Windows problem.
2
Just had a check of a more recent COBOL spec. In the section on numeric literals, for fixed-point ones it says “the implementor shall allow for fixed-point numeric literals of 1 through 31 digits in length”. For floating-point, it says “the significand shall be from 1 to 36 digits in length”, while the exponent has a maximum of 4 digits. So there are your official language limits for literals in COBOL.
2
long double will work. Also, this: #include <stdio.h> typedef _Decimal32 /* also available: _Decimal64, _Decimal128 */ real; typedef long double /* no printf support for decimal types (yet), so convert to binary for printing */ ioreal; int main(void) { const real a = 0.1df; const real b = 0.2df; const real c = a + b; fprintf(stdout, "%.17llf + %.17llf = %.17llf\n", (ioreal)a, (ioreal)b, (ioreal)c); return 0; } /*main*/
1
Oh well ... roll on decimal floats!
1
Actually, even if you use double instead of long double in that program, the output error is still just one unit in the last place, instead of something like 4 units without the use of decimal floats.
1
@groszak1 That’s in binary. It works in decimal.
1
@groszak1 It’s been in IEEE754 since 2008.
1
@groszak1 It will also come to the standards for major languages like C. Software implementations are available for them. Hardware will follow.
1