Information Technology Reference
In-Depth Information
What happened in these last two reports was exactly what occurred to me when I
created the report I referred to earlier. Obviously the problem has to do with rounding and
I explained that limitation to the person who requested this report. That was the first
possible solution to the discrepancy but the user wouldn't buy it. What would you do
under these circumstances?
From the last two reports you can see that there doesn't seem to be a lot that can
be done. The user wanted that total percentage to always be 100%, which was obtained by
adding down the column. In the last report, with rounding the number became 102%, but
without rounding we get 96%. What I did was to simply change that number at the
bottom right so that it was never anything but 100%. I'm not sure if that was accepted or
when someone challenged that perfect number I answered that they probably added
wrong. I just know that this problem has to occur from time to time - as clearly illustrated
by my bogus web reports - and outside of my second solution, there is not very much that
can be done about it.
This scenario results because of the math of a computer, which is a bit different
from the math that we are used to, unless we were weaned on calculators. If you think
that this is something, prepare yourself for some more shocks. Consider the following
variables and statements:
define w decimal (3)
define x decimal (3.1)
define y decimal (3.1)
define z decimal (3.1)
x = 1/3
y = 1/3
z = 1/3
w = x + y + z
The result for the variable
w
will be 0 if no rounding occurs and .9 if we define the field
w
as
decimal (3.1).
We expect that the result should be 1 from adding 1/3 + 1/3 + 1/3 - that's what our math
teacher should have taught us. Just the fact that we have defined the first three variables
as
decimal (3.1)
will result in truncation since each will have a value of .3 after the first three assign
statements. What happens if we change each of the four variables to
decimal (3.2) ?
In this case will each of the first three variables will be .33 after the first three assign lines
and now w will be .99, so we're getting closer to 1. We will get even closer to 1 by
Search WWH ::




Custom Search