On Sun, 12 May 2013 22:13:58 -0500, Robert Wessel
<
robert...@yahoo.com> wrote:
>On Mon, 13 May 2013 00:57:11 +0000 (UTC), Doug Miller
><
doug_at_mil...@example.com> wrote:
>
>>"Pete Dashwood" <
dash...@removethis.enternet.co.nz> wrote in news:avar7bFslqoU1
>>@
mid.individual.net:
>>
>>> Pete Trashwood wrote:
>>>> On 2013-05-12, Doug Miller <
doug_at_mil...@example.com> wrote:
>>>>> eselick <
ese...@gmail.com> wrote in
>>>>> news:599b5508-65a7-43df-bc9f-0b92c1e511d9 @
googlegroups.com:
>>>>>
>>>>>> Hi
>>>>>>
>>>>>> The following formula gives $5.88/hr in MF cobol V3.2 on Unix which
>>>>>> is incorrect.
>>>>
>>>> I'm going with Doug on this one. It sure looks correct to me.
>>>>
>>>>>> Working storage:
>>>>>>
>>>>>> 77 WS-HRS-WRK PIC 9(2)V9(6) COMP.
>>>>>> 77 WS-DOL-HR PIC 9(2)V9(2) COMP.
>>>>>> 77 WS-DOL-ERN PIC 9V9(2) COMP.
>>>>
>>>> Does your compiler not have packed decimal support? Doing money calcs
>>>> in binary is a sure way to get your incompetent ass fired. I wouldn't
>>>> want to be you.
>>>>
>>>>>> The same formula in Excel gives $5.93/hr which is the correct
>>>>>> answer.
>>>>>
>>>>> No, it is not. Do it with pencil and paper, or pick up a calculator,
>>>>> and you will see that the correct answer is indeed 5.88, not 5.93.
>>>>
>>>> Yep it sure is and I have some serious questions about this guy and
>>>> how he got this job.
>>>
>>> You are obviously no relation to me.
>>>
>>> I post under my own name because I have the courage of my convictions, and I
>>> don't need to hide behind an alias.
>>>
>>> I also accept that some people will be pissed off with my posts but most of
>>> them also have the balls to say so to my face.
>>>
>>> Pete.
>>>
>>Nevertheless, his point is valid: doing money calculations in binary *is* a very bad idea.
>
>
>To agree with Richard: completely wrong.
>
>Currency calculations need to be done in properly scaled (almost
>always decimal scaled) fixed point arithmetic. *FP* is certainly a
>bad idea most of the time.
>
>Decimal scaling is somewhat more convenient if you have decimal
>arithmetic facilities, but that's, and the greater similarity to some
>I/O formats are only advantages.
>
>In fact the Cobol spec doesn't specify the internal representation*,
>but it does specify the results of arithmetic operations. Any
>fiddling needed to accomplish that is the job of the compiler, and the
>result of:
>
> 01 A PIC 9(9)v9(3) USAGE x.
> 01 B PIC 9(5)v9(6) USAGE x.
> 01 C PIC 9(10)v9(4) USAGE x.
>
> COMPUTE C = A * B.
>
>is the same if USAGE specifies a display binary or decimal format.
>
>Again, doing currency in floating point is bad idea.
>
That depends. If your COBOL has the new IEEE decimal floating point
(which the IBM z series COBOL doesn't despite Mike Cowlishaw having
played a major role in developing it while he was still at IBM and
working as an IBM fellow), it is designed for financial transactions
and supports multiple forms of rounding including rounding half to the
nearest even - 6.5 and 5.5 both round to 6. The failure by IBM COBOL
to support the IEEE floating point and the decimal floating point
despite the fact that Java supports them and IBM COBOL OO is to
support interface with Java is something that baffles and angers me.
Clark Morris
>
>*OK, these days it does get into that a bit, but it didn't used to,
>and what COMP-x actually meant was quite undefined.