With appologies to the original poet .. who was talking about alchohol
and liver problems ...

The below bug took down a site today and hasn't been seen until now in
a long time of using the comparisons where double precision numbers
are in use. It's a late Intel Pentium, not the one with the math bug
in the chip. The compiler is set to FLOATING POINT EMULATION. So,
just how does one ever become a real good behind the scenes bookkeeper
or mission control programmer under the following bug I'll illustrate?
Sure I can put in a conditional value that excludes number results
so small as to be infinitesimal in EVERY calculation! But that
would mean re-writing all the code for double precision numbers
everywhere and that is a *LOT* of work... gloom.
If I do that here in this instance to trap what we just found, and
let it post, how do I keep the infintesimal residual from destroying
a complete fully balanced accounting system or servo control operation
for heavy equipment, for example?
I offer for show and tell:
Got a suggestion as to live with this deal. True, a bottle in front of
me is better than a frontal lobotomy, but gee folks ...

------------------
Mike Luther
[email protected]
and liver problems ...

Some little bug will find you some day.
Some little bug will get behind you some day.
With a nervous little quiver, the numbers won't deliver!
Some little bug will find you some day.
Some little bug will get behind you some day.
With a nervous little quiver, the numbers won't deliver!
Some little bug will find you some day.
a long time of using the comparisons where double precision numbers
are in use. It's a late Intel Pentium, not the one with the math bug
in the chip. The compiler is set to FLOATING POINT EMULATION. So,
just how does one ever become a real good behind the scenes bookkeeper
or mission control programmer under the following bug I'll illustrate?
Sure I can put in a conditional value that excludes number results
so small as to be infinitesimal in EVERY calculation! But that
would mean re-writing all the code for double precision numbers
everywhere and that is a *LOT* of work... gloom.
If I do that here in this instance to trap what we just found, and
let it post, how do I keep the infintesimal residual from destroying
a complete fully balanced accounting system or servo control operation
for heavy equipment, for example?
I offer for show and tell:
Code:
10 ' JUNK.BAS failure example for PB 3.5 after a site crash 11-Nov-2001 CLS PRINT "Let's examine double precision for real world tasks? OK? PRINT ' Play like we read from a text data file on a disk or COMM stream. P1$ = "456.48" ' Use string from disk file P2$ = "-30.00" ' Use string from disk file P3$ = "-152.16" ' Use string from disk file P4$ = "-84.38" ' Use string from disk file P5$ = "-189.94" ' Use string from disk file ' Compare the values to compute the AMOUNT vs SUM OF PAYOFF'ss QMT# = VAL(P1$) ' We need enough to pay this amount PRINT " We need to pay "; QMT#; "w/pmts of 30.00/ 152.16/ 84.38/ 189.94 QMV# = QMT# ' Creat a step variable watch QMP1# = VAL(P2$) ' Payment #1 QMP2# = VAL(P3$) ' Payment #2 QMP3# = VAL(P4$) ' Payment #3 QMP4# = VAL(P5$) ' Payment #4 QMM# = QMM# + QMP1# ' Add a payment to holding variable QMV# = QMV# + QMP1# ' Decrement step variable PRINT " After step 1 "; QMV# ' Print step variable QMM# = QMM# + QMP2# ' Add a payment to holding variable QMV# = QMV# + QMP2#' Decrement step variable PRINT " After step 2 ";QMV#' Print step variable QMM# = QMM# + QMP3# ' Add a payment to holding variable QMV# = QMV# + QMP3#' Decrement step variable PRINT " After step 3 ";QMV#' Print step variable QMM# = QMM# + QMP4# ' Add a payment to holding variable QMV# = QMV# + QMP4#' Decrement step variable PRINT " After step 4 ";QMV#' Print step variable PRINT " Our debt was "; QMT# ' Print debt PRINT " Our payments were "; QMM# ' Print payoff total ' We have now enough money to pay this invoice PRINT " Amount needed for payoff = "; QMT# + QMM# PRINT " So much for double entry bookeeping in PowerBASIC?" PRINT PRINT " Now let's do this in array work too!" ' Now dimension double precision arrays and do this in them DIM QAMT#(350) ' Dimension double precision array DIM QAMP#(350) ' Dimension double precision array DIM QAMM#(350) ' Dimension double precision array QAMT#(1) = VAL(P1$) ' We need enough to pay this amount QAMP#(1) = VAL(P2$) ' Payment #1 QAMP#(2) = VAL(P3$) ' Payment #2 QAMP#(3) = VAL(P4$) ' Payment #3 QAMP#(4) = VAL(P5$) ' Payment #4 QAMM#(1) = QAMM#(1) + QAMP#(1) ' Add a payment to holding variable QAMM#(1) = QAMM#(1) + QAMP#(2) ' Add a payment to holding variable QAMM#(1) = QAMM#(1) + QAMP#(3) ' Add a payment to holding variable QAMM#(1) = QAMM#(1) + QAMP#(4) ' Add a payment to holding variable PRINT " Our debt was "; QAMT#(1)' Print debt PRINT " Our payments were "; QAMM#(1)' Print payoof total PRINT " Amount needed for payoff = "; QAMT#(1) + QAMM#(1) PRINT " So much for double entry bookeeping in PowerBASIC?" PRINT PRINT " Just a thought .... " PRINT PRINT " If this were course corrections, and we fired that " PRINT " booster rocket until we had 'er right on track .. PRINT " so, grin, where did Mariner X go? PRINT PRINT " But just in case you think the answer is simple, <CR>:"; ZZ0$ = INPUT$(1) CLS PRINT PRINT " Maybe not! Compare just the bottom increment!" PRINT P6$ = " 189.94" ' Use string from disk file P7$ = "-189.94" ' Use string from disk file QMT# = VAL(P6$) ' Convert this to number variable QMN# = VAL(P7$) ' Convert this to number variable PRINT " String to compare is: "; P6$ ' Show actual string PRINT " String accumulate is: "; P7$ ' Show actual string PRINT " Amount to compare is: "; QMT# ' Show number variable PRINT " Amount to compare is: "; QMN# ' Show number variable PRINT PRINT " Amount needed for payoff = "; QMT# + QMN# ' Print comparator
me is better than a frontal lobotomy, but gee folks ...

------------------
Mike Luther
[email protected]
Comment