HP3000-L Archives

October 2008, Week 3

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Jim Phillips <[log in to unmask]>
Reply To:
Date:
Wed, 15 Oct 2008 05:50:36 -0700
Content-Type:
text/plain
Parts/Attachments:
text/plain (67 lines)
On Tue, 14 Oct 2008 16:49:51, Tony Girgenti <[log in to unmask]> wrote:

<snip>

> If i multiply this out on a calculator:
> 142.79 / 110.23 * 100.000 = 129.5382
>
> My puzzlement lies in the mystery of why a ROUNDED option causes less
> rounding than a COMPUTE without the ROUNDED option.
>
> I'm more concerned about finding out a way to get the answer of:
> LINE-ITEM-UNIT-PRICE= 129.54
> LINE-ITEM-UNIT-COST= 129.538
>
> I'm not so concerned about why it is happening as much as how to make it 
> give the results I want.
>
> Any help would be gratefully appreciated.

Here is how I made it work for me:

   05  LINE-ITEM-UNIT-PRICE    PIC S9(5)V9999 COMP VALUE 0.
   05  LINE-ITEM-UNIT-PRICE2   PIC S9(5)V99 COMP VALUE 0.
   05  LINE-ITEM-UNIT-COST     PIC S9(5)V9999 COMP VALUE 0.
   05  LINE-ITEM-UNIT-COST2    PIC S9(5)V99 COMP VALUE 0.
   05  STOP-TARIFF-RATE        PIC S9(5)V9999 COMP VALUE 142.79.
   05  STOP-COST-RATE          PIC S9(5)V9999 COMP VALUE 142.79.
   05  ORDER-TOTAL-WEIGHT      PIC S9(5)V9999 COMP VALUE 110.23.
   05  OHP                     PIC S9(3)V9999 COMP VALUE 100.

. . .

     COMPUTE LINE-ITEM-UNIT-PRICE ROUNDED =
             STOP-TARIFF-RATE / ORDER-TOTAL-WEIGHT * OHP
         ON SIZE ERROR
             MOVE ZEROES         TO LINE-ITEM-UNIT-PRICE.
  
     COMPUTE LINE-ITEM-UNIT-COST ROUNDED =
             STOP-COST-RATE / ORDER-TOTAL-WEIGHT * OHP
         ON SIZE ERROR
             MOVE ZEROES         TO LINE-ITEM-UNIT-COST.
  
     COMPUTE LINE-ITEM-UNIT-PRICE2 ROUNDED =
             LINE-ITEM-UNIT-PRICE.
     COMPUTE LINE-ITEM-UNIT-COST2 ROUNDED =
             LINE-ITEM-UNIT-COST.

. . .

ROUNDED RESULTS:
   LINE-ITEM-UNIT-PRICE = +00129.5380
    LINE-ITEM-UNIT-COST = +00129.5380
   LINE-ITEM-UNIT-PRICE2= +00129.54
    LINE-ITEM-UNIT-COST2= +00129.54


HTH


Jim 


      

* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

ATOM RSS1 RSS2