Rounding question

Deskin, Bob Bob.Deskin@Cognos.COM
Tue, 3 May 2005 12:08:43 -0400


The issue is probably caused by the fact that PowerHouse does its
arithmetic in floating point. I have found that the best way to round is
to add .5 and then FLOOR. However this means that you have to deal with
the appropriate power of ten and output scaling. The intent of the ROUND
function was to handle things using the input converted to floating
point and proceed from there. As for the FLOOR function, it lowers the
value to the nearest integer, so if you've already got a floating point
number with decimal places, you have to scale by appropriate powers of
10 and the adjust.

Bob

-----Original Message-----
From: powerh-l-admin@lists.sowder.com
[mailto:powerh-l-admin@lists.sowder.com] On Behalf Of Guy Werry
Sent: May 3, 2005 11:47 AM
To: PH Mailing List (E-mail)
Subject: Rounding question


Ph 7.33.D3, Ux 10.20

The rounding function is giving me fits.  Specifically, I have a value
in a FLOAT data item and was rounding it like this:
	round(inp_val,3,near)

So I'm trying to round to 3 decimals.  If I enter 0.0015, it rounds DOWN
to 0.001!

I have tried various combinations of the "multiply by 1000, round it,
divide by 1000" rigamarole, with no success.

Is there a clean, neat solution to this?  Is there some way of telling
the stupid thing to round UP on that 5?  Note that the "UP" and "DOWN"
options don't give the results that I need.

[The frustration mirrored here is largely due to the fact that COBOL
rounds wonderfully and predictably and I've NEVER found another language
that could round its way out of a wet paper bag!]

Thanks,
Guy L. Werry
Senior Systems Analyst
Hudson Bay Mining & Smelting Co., Limited. 



-- 
= = = = = = = = = = = = = = = = = = = = = = = = = = = =
Mailing list: powerh-l@lists.sowder.com
Subscribe: "subscribe" in message body to
powerh-l-request@lists.sowder.com
Unsubscribe: "unsubscribe <password>" in message body to
powerh-l-request@lists.sowder.com
http://lists.sowder.com/mailman/listinfo/powerh-l
This list is closed, thus to post to the list you must be a subscriber. 
  
       This message may contain privileged and/or confidential information.  If you have received this e-mail in error or are not the intended recipient, you may not use, copy, disseminate or distribute it; do not open any attachments, delete it immediately from your system and notify the sender promptly by e-mail that you have done so.  Thank you.