home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload
/
ShartewareOverload.cdr
/
database
/
numtest.zip
/
NOTRIGHT.PRG
< prev
Wrap
Text File
|
1988-11-08
|
3KB
|
109 lines
** Tests the bizarre bug in numeric logical comparison
** 11/7/88
**
** Ron Landberg
** 4126 Joan Ave.
** Concord, CA 94521
** [415] 682-3226
**
**
****************************************************************************
** RUN THE PROGRAM TWICE USING THE TWO SETS OF NUMBERS LISTED ON THE SCREEN.
****************************************************************************
**
**
*********************************
**
** Compile & Link:
**
** CLIPPER notright
** TLINK notright,,,clipper /x/d
**
********************************
****************************************************************************
**
** Description:
**
** DEMONSTRATES A BUG IN CLIPPER NUMBER HANDLING
**
** Compares a numeric memory variable, previously assigned the value of a
** numeric database field (Len:8,Decml:2), to the result of an addition of
** two numeric keyboard entries. Displays the result of 5 logical compari-
** sons.
** (All comparisons are between the assigned memory variable and the calcul-
** ated variable except for the one described as `DIRECTLY' which is a
** comparison made between the actual field value and the calculated vari-
** able - eliminates the assigned variable `num_var' from the comparison)
**
** Obviously, the results should be exactly the same since the only change
** in the second set of numbers is the switch of a penny in each entry which
** offset each other.
**
****************************************************************************
***************************************************
** ARC File contains: NOTRIGHT.PRG and NOTGOOD.DBF
***************************************************
SET FIXED ON
SET DECIMAL TO 2
CLEAR
USE notgood
GO top
num_var = dollars && Assign a numeric field value to memory variable
@ 16,50 to 22,70
@ 17,51 say "Enter these numbers"
@ 18,51 say "231.92 4.73"
@ 19,51 say "Then rerun program "
@ 20,51 say "with these numbers "
@ 21,51 say "231.91 4.74"
@ 18,20 to 20,44
@ 19,21 say "Field value= "+ltrim(str(num_var,8,2))
the_tot = 0 && Will hold the total of the two keyboard entries
SET CONFIRM ON
FOR x = 1 TO 2
a_partial=0
@ 10,10 GET a_partial PICT '99,999.99'
READ
the_tot = the_tot + a_partial
NEXT
SET CONFIRM OFF
? "The field value = "
?? num_var
?
? "The accumulated total = "
?? the_tot
?
?"----------------------------------------------------------------"
? "Is the accumulated total equal to the field value ? "
?? (the_tot = num_var)
? "Is the accumulated total exactly equal to the field value ? "
?? (the_tot == num_var)
? "Is the accumulated total equal DIRECTLY to the field value? "
?? (the_tot = notgood->dollars)
? "Is the accumulated total greater than the field value ? "
?? (the_tot > num_var)
? "Is the accumulated total less than the field value ? "
?? (the_tot < num_var)
? "Is the field value greater than the accumulated total ? "
?? (num_var > the_tot)
?
?
use
quit