|
This is a perfectly fine algorithm. In the syntax we've been using to date, the actual answer for this class of problems is: int((x - delta) / y) * z where delta is any sufficiently small number. "Sufficiently small" simply means smaller than the smallest unit of measurement, in this case a penny. Thus this will ALWAYS work for any amount with a precision of .01 (or greater): Fee = %int( (650 - .001) / 500) * 4.00 In the real world of applied mathematics, using your working set to determine your boundary conditions is acceptable and in fact often required. The correct algorithm is the one which gets you the correct results all the time. Joe > From: Scott Klement > > > > > > fee = 4.00 * %int(1 + (650 / (500.00 + .01) ) > > With that code, $1000.01 will only be charged for 2 * 4.00 instead of the > proper 3 * 4.00. Please stop trying to fix a faulty algorithm by > inserting different numbers into it.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.