4302836 4302836 - 3 months ago 7
Java Question

set maximum 3 digit decimal value in in database

I want to store the data in maximum three digit after decimal point in data base using hibernate
My Value Storing in db having

column property double 124323.76754287

while I want to store

If possible Please help me.


Play with a table design and test overflow possibilities.

create table numTests
(   id int auto_increment primary key,
    d2 decimal(10,2) not null,
    d3 decimal(10,3) not null,
    myF float not null,
    myD double not null
insert numTests(d2,d3,myF,myD) values
(122.226,122.226,122.2223333,333.44444444); -- decimal place truncate on d2

insert numTests(d2,d3,myF,myD) values
(122.12,122.226,122.2223333,333.44444444); -- no truncate

MySQL Manual Pages entitled Numeric Types and Fixed-Point Types (Exact Value) - DECIMAL, NUMERIC

It would appear that you want to shoot for DECIMAL.