× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Rounding up is (or at least was) used in calculating sales tax in Illinois, to - if my memory is working today - 5 decimal places
2.70000 becomes 2.70
2.70001 becomes 2.71

I had to code for that 15 years ago, now we use a service

Alan Shore
E-mail : ASHORE@xxxxxxxx
Phone [O] : (631) 200-5019
Phone [C] : (631) 880-8640
'If you're going through hell, keep going.'
Winston Churchill

-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxxxxxxxx] On Behalf Of John Yeung
Sent: Wednesday, February 12, 2020 12:15 PM
To: RPG programming on IBM i <rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: [EXTERNAL] Re: What is a good way to round up numbers in free form?

On Wed, Feb 12, 2020 at 10:30 AM <dlclark@xxxxxxxxxxxxxxxx> wrote:

EVAL(h) should do that. However, this may be considered
overkill, but I created a service procedure to give us complete
flexibility in rounding.

This is the kind of thing that I think is fun in programming, and no doubt you enjoyed writing it.

I wonder if you could extend it so that it provides *real world* flexibility. The kind of flexibility you've described, where you choose a single break point above which everything rounds up, is actually not one that I have ever heard of anyone needing.

What many people in the real world *do* need is the ability to round toward even. That is, 1.5 rounds to 2.0, but 4.5 rounds to 4.0. (It's much less common to want to round toward odd, but maybe that's something that ought to provided if round-toward-even is provided, because "why not?". And for symmetry.)

You can read about the many established rounding methods on Wikipedia:

https://en.wikipedia.org/wiki/Rounding

The other major axis of useful flexibility is allowing the choice of always rounding toward (or always away from) positive infinity, or always rounding away from (or always toward) zero.

The Wikipedia entry details several more rounding methods.

John Y.
--
This is the RPG programming on IBM i (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxx for any subscription related questions.

Help support midrange.com by shopping at amazon.com with our affiliate link: https://amazon.midrange.com


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.