[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

# variables in SQR



We've noticed some strange behavior in SQR when using # variables in SQR.

We're selecting a number from an Oracle database into an SQR column variable
called &SUMMARY_AMOUNT and are getting some sort of strange approximation
effect when we move that value to a SQR # variable(the Oracle field
definition is NUMBER(12,2) by the way).

Here's basically what I'm doing after getting &SUMMARY_AMOUNT:

   let #SUMMARY_AMOUNT = &SUMMARY_AMOUNT

   DISPLAY &SUMMARY_AMOUNT 99999.999999999999999
   DISPLAY #SUMMARY_AMOUNT 99999.999999999999999

And here's what the output looks like on several differnt values of
&SUMMARY_AMOUNT from the database:

   -22.500000000000000   <--database value
   -22.500000000000000   <--#variable value

   -13.630000000000000   .
   -13.630000000000001   ...etc

   -42.050000000000000
   -42.049999999999999

 -4687.000000000000000
 -4687.000000000000000

    21.100000000000000
    21.100000000000001

    20.950000000000000
    20.949999999999999

     5.000000000000000
     5.000000000000000

Sometimes they're equal, sometimes they're not.  It sure make things
difficult when trying to compare these numbers and the result is not
what it seems it should be!  Does this mean I should round # variables
at all times as a general rule?

Thanks,
Tim Harris
Systems Analyst
Oregon State University