Rounding Issue

S

srinivas.veeranki

Hi All,

I am sending BigDecimal Value(Ex : 2.6000000000000000) to the
Databe. I am using the Sybase as Data Base. In the Data Base , the
corresponding column is declared as Number(18, 16). If I sent above
value from my prog. it storing as 2.6000000000000001 in the Databse.
Can u plz suggest the solution to store the same value in the databse.
What the max size allowed after the decimal point. As per the IEEE
standards , For Double precision it is 23 bits.

Thanks & Regards,

Srinivas.
 
G

GArlington

Hi All,

I am sending BigDecimal Value(Ex : 2.6000000000000000) to the
Databe. I am using the Sybase as Data Base. In the Data Base , the
corresponding column is declared as Number(18, 16). If I sent above
value from my prog. it storing as 2.6000000000000001 in the Databse.
Can u plz suggest the solution to store the same value in the databse.
What the max size allowed after the decimal point. As per the IEEE
standards , For Double precision it is 23 bits.

Thanks & Regards,

Srinivas.

It looks like your Number in DB is stored as binary representation ->
your rounding error, try Decimal(18, 16), if it does NOT help, you
might have to store your number as Integer and scale it down.
 
L

Lew

I am sending BigDecimal Value(Ex : 2.6000000000000000) to the
Databe. I am using the Sybase as Data Base. In the Data Base , the
corresponding column is declared as Number(18, 16). If I sent above
value from my prog. it storing as 2.6000000000000001 in the Databse.
Can u [sic] plz [sic] suggest the solution to store the same value in the databse.
What the max size allowed after the decimal point. As per the IEEE
standards , For Double precision it is 23 bits.

There is no (theoretical) maximum for java.math.BigDecimal
 
R

Roedy Green

I am sending BigDecimal Value(Ex : 2.6000000000000000) to the
Databe. I am using the Sybase as Data Base.

You will have to read the Sybase docs to figure out if they have
something corresponding to big decimal, or perhaps a character
numeric, then declare your database that type.

I find it odd that after all these years the datatypes, their names
and behaviour are not defined in iron for SQL.

Then see if JDBC has something that won't wreck it in transmission. In
a pinch, use char or a byte blob.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top