P
Pastor Del
The abridged version:
I want to divide an odd whole number by 2 and deal seperately with the
quotient as a whole number & remainder as a decimal. If I use integers to
perform the calculations the quotient is wrong because it automatically
rounds up. (Sample code at bottom) How can I get the quotient to round down?
The detailed version:
I have build an application to generate travelers for my company. A
traveler accompanies our products through the manufacturing process. The
first traveler is always the sample traveler. Each traveler after that has a
traveler quantity that varies from product to product. My application
calculates the number of travelers for a particular production run by
subtracting the sample quantity from the kit quantity and then dividing the
difference by the traveler quantity for this particular product. A problem
arises when the difference mentioned above is an odd number and the traveler
quantity is 2.
With the following quantities I want my code to generate 1 sample traveler
with a quantity of 1, 249 travelers with a quantity of 2 each and a final
traveler with a quantity of 1. But because the quotient is rounded up it
generates 250 travelers with traveler quantity of 2 each.
Dim intKitQty as Integer, intSampleQty as integer, intDifference as Integer
Dim intTravelerQty as Integer, intQtyOfTravelers, intLastTravelerQty as
integer
intKitQty = 500
intSamplQty = 1
intTravelerQty = 2
intDifference = intKitQty - intSampleQty
intQtyOfTravelers = intDifference / intTravelerQty
intLastTravelerQty = intDifference Mod intTravelerQty
How can I get the intQtyOfTravelers to round down?
I want to divide an odd whole number by 2 and deal seperately with the
quotient as a whole number & remainder as a decimal. If I use integers to
perform the calculations the quotient is wrong because it automatically
rounds up. (Sample code at bottom) How can I get the quotient to round down?
The detailed version:
I have build an application to generate travelers for my company. A
traveler accompanies our products through the manufacturing process. The
first traveler is always the sample traveler. Each traveler after that has a
traveler quantity that varies from product to product. My application
calculates the number of travelers for a particular production run by
subtracting the sample quantity from the kit quantity and then dividing the
difference by the traveler quantity for this particular product. A problem
arises when the difference mentioned above is an odd number and the traveler
quantity is 2.
With the following quantities I want my code to generate 1 sample traveler
with a quantity of 1, 249 travelers with a quantity of 2 each and a final
traveler with a quantity of 1. But because the quotient is rounded up it
generates 250 travelers with traveler quantity of 2 each.
Dim intKitQty as Integer, intSampleQty as integer, intDifference as Integer
Dim intTravelerQty as Integer, intQtyOfTravelers, intLastTravelerQty as
integer
intKitQty = 500
intSamplQty = 1
intTravelerQty = 2
intDifference = intKitQty - intSampleQty
intQtyOfTravelers = intDifference / intTravelerQty
intLastTravelerQty = intDifference Mod intTravelerQty
How can I get the intQtyOfTravelers to round down?