I have a Oracle Database version 11g Release 11.2.0.3.0 and after updating a numeric (30,20) row, I discovered some awful behavior. Running update table set column = 9999999999.00390625 where someClause
was okay, but selecting the same value resulted in 9999999999.003910450000000000
.
I know about this issue and noticed stack overflow's warning about it. My question is:
Using Oracle 11g, is there any method or means available to deal with this imprecision? I thought about saving my number in 2 pieces (decimal and integer parts) and using some logic to sum them up before giving it back to who requested. But is this some boilerplate code?
EDIT
This is what all_tab_cols returned with respective where clause:
DATA_TYPE NUMBER
DATA_LENGTH 22
DATA_PRECISION 30
DATA_SCALE 20
NULLABLE Y
COLUMN_ID 2
DATA_DEFAULT <Long>
NUM_DISTINCT 12
LOW_VALUE 80
HIGH_VALUE BE640D51
DENSITY 0,0833333333333333
NUM_NULLS 0
NUM_BUCKETS 1
LAST_ANALYZED 07/07/2011 15:49:11
SAMPLE_SIZE 56
GLOBAL_STATS YES
USER_STATS NO
AVG_COL_LEN 4
CHAR_LENGTH 0
V80_FMT_IMAGE NO
DATA_UPGRADED YES
HIDDEN_COLUMN NO
VIRTUAL_COLUMN NO
SEGMENT_COLUMN_ID 2
INTERNAL_COLUMN_ID 2
HISTOGRAM NONE
All empty column values were omitted, as well as column, table and user names. I checked that no triggers are applied to this table and our Java application showed same value as PL/SQL Developer (pink one) as a proof this isn't some client problem.
Actually, using 0.00390625
instead of 9999999999.00390625
resulted no misbehavior, kind of proving the floating point problem's cause.