Re: 4GL 4.11 decimal equality bug
Posted in 1995
When I ran this program on 4GL ver. 6.00.UE3 i got the two decimals equal. Generally this is a problem however. At least last time I checked (using 4GL ver. 4.1? 4GL kept all decimal type variables internally as floating point decimals altough they were defined as decimal (10,2) We got rounding errors in a similar situation although that shouldn't be possible. The program variables kept track of digits beyond the second after the decimal point! These where removed of course as soon as it was inserted into the database. To get around this we had to make a round function that multiplied with 100, put the variable into an integer variable and returned this devided by 100. This is of course only possible if the numbers are small enough to be stored in an integer. The only other solution I know is to insert them into the database and read them back - hardly viable in most cases, but... Yes, in my opinion this is a *bug*. I found this out a long time ago, when Informix support was not very good, and I was not on the net, so I have never reported it. I don't know if this is a known bug that is or will be fixed. It should be though. Nils.Myklebust@ccmail.telemax.no NM-data, Dalsbergstien 7, N-0170 Oslo, Norway My opinions are those of my company } james@bi-tech.com ("James Bennett") writes: } I'm having an odd problem with 4GL (4.11) decimal types used in an } equality test. A sample program does a calculation, displays } two decimal(18,2) values (which appear equal) and then tests for } equality (which fails). I wrote a C program to dump the dec_t } structures, and this is what showed up. } } Variable A } exp = 3 pos = 1 N=4 digits = (3 45 0 0) which equals 34500 } } Variable B } exp =3 pos =1 N=2 digits = (3 45) which also equals 34500 } } For some reason, 4GL feels these two variables are not equal. IMHO } opinion this is a *bug*, but I'm curious if it is fixed on later } releases (please not 4.12, though). } } Here is my sample program: } } main } define PriorAccDepr decimal(18,2) } define MonthDepr float } define MonthDiff smallint } define FAAccAmt decimal(18,2) } define diff decimal(20,10) } } let MonthDiff = 84 } let FAAccAmt = 34500.0 } } let MonthDepr = (36000 - 1500) / 84 } let PriorAccDepr = MonthDepr * MonthDIff } } { call dumpdec(faaccamt,prioraccdepr) (my c routine) } } } -- Now, both FAActAMmt s/b the same } } if FAAccAmt = PriorAccDepr then } display "=" } end if } if FAAccAmt < PriorAccDepr then } display "<" } end if } } let diff = FAAccAmt - PriorAccDepr } display "diff = ", diff using "###,###.##########" } } end main } } Any thoughts? } } }>>> Nils.Myklebust@ccmail.telemax.no NM-data, Dalsbergstien 7, N-0170 Oslo, Norway My opinions are those of my company