[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Strange add results
- From: Mark Hamburg <mark@...>
- Date: Sun, 21 Nov 2010 10:34:35 -0800
Binary floating point arithmetic v decimal notation.
This is why COBOL still has a place.
Somewhere I saw a rundown on the things that COBOL offers that other would be replacements (C++, Java, etc) have failed to offer. As I recall, it included built-in support for fixed-place decimal notation (so that programmers don't have to know about this issue or shift to storing everything in pennies or...) and the fluidity of moving values between records. My favorite bit of COBOL is MOVE CORRESPONDING:
MOVE CORRESPONDING FROM A To B
would in Lua be essentially:
-- Copy the overlapping fields from a to b
function move_corresponding_from_to( a, b )
for k, v in pairs( a ) do
if b[ k ] ~= nil then
b[ k ] = v
This is actually pretty useful when processing one stream of records to produce another stream. It does highlight the issue that one needs to have nil be a significant value and reserve it for use as "missing".