Stories
Slash Boxes
Comments

SoylentNews is people

posted by martyb on Monday September 16 2019, @01:48PM   Printer-friendly
from the COBOL-is-often-fractionally-better dept.

https://medium.com/@bellmar/is-cobol-holding-you-hostage-with-math-5498c0eb428b

Face it: nobody likes fractions, not even computers.

When we talk about COBOL the first question on everyone's mind is always Why are we still using it in so many critical places? Banks are still running COBOL, close to 7% of the GDP is dependent on COBOL in the form of payments from the Centers for Medicare & Medicaid Services, The IRS famously still uses COBOL, airlines still use COBOL (Adam Fletcher dropped my favorite fun fact on this topic in his Systems We Love talk: the reservation number on your ticket used to be just a pointer), lots of critical infrastructure both in the private and public sector still runs on COBOL.

Why?

The traditional answer is deeply cynical. Organizations are lazy, incompetent, stupid. They are cheap: unwilling to invest the money needed upfront to rewrite the whole system in something modern. Overall we assume that the reason so much of civil society runs on COBOL is a combination of inertia and shortsightedness. And certainly there is a little truth there. Rewriting a mass of spaghetti code is no small task. It is expensive. It is difficult. And if the existing software seems to be working fine there might be little incentive to invest in the project.

But back when I was working with the IRS the old COBOL developers used to tell me: "We tried to rewrite the code in Java and Java couldn't do the calculations right."

[Ed note: The referenced article is extremely readable and clearly explains the differences between floating-point and fixed-point math, as well as providing an example and explanation that clearly shows the tradeoffs.]


Original Submission

 
This discussion has been archived. No new comments can be posted.
Display Options Threshold/Breakthrough Mark All as Read Mark All as Unread
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
  • (Score: 3, Informative) by FatPhil on Tuesday September 17 2019, @07:20AM (5 children)

    by FatPhil (863) <pc-soylentNO@SPAMasdf.fi> on Tuesday September 17 2019, @07:20AM (#895054) Homepage

    Kahan is one of the guys who wrote the IEEE754 floating point standards. Hasn't been a research academic for a long time, but over the decades has published a whole bunch of reports on what can go wrong with FP, including at the language-implementation level, such as How JAVA's Floating-Point Hurts Everyone Everywhere [berkeley.edu] (PDF file) whose title should be self-explanatory.

    --
    Great minds discuss ideas; average minds discuss events; small minds discuss people; the smallest discuss themselves
    Starting Score:    1  point
    Moderation   +1  
       Informative=1, Total=1
    Extra 'Informative' Modifier   0  
    Karma-Bonus Modifier   +1  

    Total Score:   3  
  • (Score: 2) by DannyB on Tuesday September 17 2019, @02:23PM (4 children)

    by DannyB (5839) Subscriber Badge on Tuesday September 17 2019, @02:23PM (#895151) Journal

    That is interesting.

    It is from 1998, over twenty years ago. Java has changed a lot -- but I don't know how much in relation to this topic.

    There are a few rebuttals I could make -- but, I don't use floating point much in Java. But I've never had a problem with it.

    Since I mostly work with BigDecimal (which is really an unlimited precision integer underneath), I don't have the inexactness of floating point approximations of money values.

    --
    People today are educated enough to repeat what they are taught but not to question what they are taught.
    • (Score: 2) by FatPhil on Tuesday September 17 2019, @02:51PM (3 children)

      by FatPhil (863) <pc-soylentNO@SPAMasdf.fi> on Tuesday September 17 2019, @02:51PM (#895160) Homepage
      The complaints are mostly from an HPC persepective, big simulations and modelling, with lots of feedback and opportunities for seemingly trivial inaccuracies can have larger cascading consequences. Finance is abacus work compared to that.

      Having a specific type for currency values is ideal (as long as you can trust the implementer of that black box). It can also help with dimensional correctness too, if you have strict typing.
      --
      Great minds discuss ideas; average minds discuss events; small minds discuss people; the smallest discuss themselves
      • (Score: 3, Interesting) by DannyB on Tuesday September 17 2019, @03:32PM (2 children)

        by DannyB (5839) Subscriber Badge on Tuesday September 17 2019, @03:32PM (#895191) Journal

        Microsoft, amusingly, has a type for currency. It is basically your standard 2s compliment 64 bit integer with an implied decimal point four places from the right. So it counts in hundredths or a cent, or ten-thousandths of a dollar -- or whatever unit of currency in use.

        I would like to see more languages that can attach dimensional correctness to scalar values, which in turn can be carried into more complex types such as rational values, complex numbers, etc. It would be a compile time error to have incorrect dimensions.

        But when I muse about higher level and more abstract languages, I am often taken to task for it because programming should always be only about working at the bits and bytes and cpu cycles.

        --
        People today are educated enough to repeat what they are taught but not to question what they are taught.
        • (Score: 2) by FatPhil on Wednesday September 18 2019, @08:19AM (1 child)

          by FatPhil (863) <pc-soylentNO@SPAMasdf.fi> on Wednesday September 18 2019, @08:19AM (#895536) Homepage
          Never knew about the MS centi-cents - interesting. That has the side effect of still forcing the programmer to do with the centi-cents they don't want to propagate to the outside world (invoice/etc.). I don't like the implication that every single step of a financial calculation will be performed in this type, because the errors would accumulate at a terifying rate compared with how quickly they would if you were performing the calculations in FP, unless everything you are dealing with was multi-billion. I fear this might be a half-baked idea. Inside the black box, always use the best tool for the job. There really needs to be 2 currency types - currency-for-userspace and currency-for-calculations - where the user should never see or use the latter.
          --
          Great minds discuss ideas; average minds discuss events; small minds discuss people; the smallest discuss themselves
          • (Score: 2) by DannyB on Wednesday September 18 2019, @01:58PM

            by DannyB (5839) Subscriber Badge on Wednesday September 18 2019, @01:58PM (#895640) Journal

            Microsoft has had its currency type since at least the 1990's. It is in all their languages, as far as I know, but started in VB, I think. At the time it probably seemed like a good idea. And it probably stopped many programmers from using floating point instead.

            --
            People today are educated enough to repeat what they are taught but not to question what they are taught.