currently they manually round up. Yes 2 pounds becomes 3 pounds,. What this
is, is that we will get the Worldship software from UPS. instead of manually
weighing each package we will supply UPS with the weight and service, model
number and QTY. This I get from our files. THen it goes into Worldship via a
file batch update. THen the user calls up Worldship, scans the printed
invoice number into Worldship and it provides them with information for
packing and so forth.
SInce there is leeway in the packing it makes more sense to round up the
numbers than to precisely weigh each one,
Although I would love to hear how other folks are doing this for the consumer
marketplace via Worldship.
Thanks
--- On Tue, 5/20/08, Adam Glauser <adamglauser@xxxxxxxxxxxx> wrote:
From: Adam Glauser <adamglauser@xxxxxxxxxxxx>
Subject: Re: Technique for rounding up
To: rpg400-l@xxxxxxxxxxxx
Date: Tuesday, May 20, 2008, 1:04 PM
Adam West wrote:
> the problem is with a whole number, something that weighs 2 pounds.
> Currently, they manually round up to next pound regardless. but 2
always
> remains at 2.
Are you describing the correct behaviour for the algorithm, or the
incorrect behaviour that you want to correct? That is, if you have
weight = 2.0, should the result be 2.0 or 3.0?
In the first case, the CEILING function mentioned by Birgitta is as good
a choice as any. The ceil() function is also callable as part of the
C/C++ runtime. Booth's suggestion is a way to implement the CEILING
function if choose not to use embedded SQL or an API call, but be aware
that it will need to be modified depending on the number of decimal
places in your weight field:
%int(2.01 + 0.9) = %int(2.91) = 2.0
In case you want 2.0 to become 3.0, you could use
newWeight = FLOOR(originalWeight + 1).
Hope this helps,
Adam
--
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at
http://archive.midrange.com/rpg400-l.
As an Amazon Associate we earn from qualifying purchases.