Re: What is math:intdiv doing?
- Posted by _tom (admin) Mar 31, 2015
- 1753 views
Thanks Lonny and Shian,
I found a solution to "intdev" which I now call intact division.
_tom
intdiv
include intdiv.ex public function intdiv(object dividend, object divisor)
returns an intact division of two objects.
Arguments:
- dividend : any Euphoria object.
- divisor : any Euphoria object.
Returns:
An object, which will be a sequence if either dividend or divisor is a sequence.
Comments:
Starting with a number of items, how many containers are needed when each container has a fixed maximum size? Since you can not have a fractional container you must perform what we will call an intact division. Every container will be full of items except that the last container could be partially full--every container remains intact.
- The dividend is the number of items to be packed.
- The divisor is the size of the container.
- The return is the number of intact containers.
Example 1:
include std/math.e atom tokens = 101 atom perEnvelope = 5 ? 101/5 --> 20.2 -- but, can not have 0.2 envelopes integer envelopes = intdiv( tokens, perEnvelope ) ? envelopes --> 21