java - Jtds SetFloat inputs Uneven Values in Database(Miscrosoft Sql Server) -


i trying input values in sql server database using setfloat

jtdsproc.setfloat(12, nb.getopenamount());

my amount 1.20 in database entering 1.199999523 want enter till 2 digits set float making problem how enter float value goes till 2 decimal .

i using jtds library connect sql server

you cannot represent number 1.2 using floating point numbers. because denominator of 1.2=6/5 not power of two. you'd design database scheme store fixed number of decimals if such things matter. in case, if java transferring value not equal 1.2, database still store value of 1.2.

as alternative, yould try transfer value string. can use decimalformat generate representation fixed number of digits, transfer string database , let handle conversion internal representation on database server. whether works better depends on whether database server has more precision thand single-precision float. if not, stored number same before.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -