3 ms·
Is that because it has a runtime decimal library that’s implemented a certain way, or because it has a native data type that uses the processor’s BCD registers?
by sonthonax 6y ago
Is that because it has a runtime decimal library that’s implemented a certain way, or because it has a native data type that uses the processor’s BCD registers?
I’m curious to know if these COBOL programs actually depend on IBM mainframes because of that.
- rbanffy 6y agoIt depends on hardware support. I’m not aware of anything that has it besides mainframes, but if it’s not there, software emulation is used. Using IEEE floats for money often has... amusing results.
- sonthonax 6y agox86 has had BCD support since before I was born. And, as far as I know, when compiling for a platform that's missing a fundamental datatype, it's usually the compiler that adds the missing type as a runtime. See for example this, a software float for crappy ARM processors. https://github.com/gcc-mirror/gcc/blob/16e2427f50c208dfe07d07f18009969502c25dc8/libgcc/config/arm/ieee754-sf.S https://github.com/gcc-mirror/gcc/blob/16e2427f50c208dfe07d0... I was more so wondering, if a COBOL compiler (given how low level the language is) makes a lot of assumptions about the platform. Even assumptions about potential quirks.
- rbanffy 6y agoI’m no COBOL expert, but the way a COBOL program sees the machine is very different from what a C program does. I never saw anything resembling assumptions about native data types or anything similarly low level. And I never imagined an x86 could deal with decimal floats.
- cratermoon 6y agoThat's how I learned about COBOL's behavior. I was on a consulting gig with some COBOL programmers that had been sent to a learn-java-in-21-days course. When I arrived I found they had used float for money, because they didn't know any better. We eventually switched over to BigDecimal, but not until the staff were convinced by continuing problems with the results. Now I just talk about Muller's Recurrence https://scipython.com/blog/mullers-recurrence/ https://scipython.com/blog/mullers-recurrence/ https://latkin.org/blog/2014/11/22/mullers-recurrence-roundoff-gone-wrong/ https://latkin.org/blog/2014/11/22/mullers-recurrence-roundo... And show people https://0.30000000000000004.com/ https://0.30000000000000004.com/ Also see https://stackoverflow.com/questions/30215023/how-cobol-handles-division-rounding-by-default/30215718#30215718 https://stackoverflow.com/questions/30215023/how-cobol-handl...