Understanding accuracy and scale on property

property name="poiLat" length="60" ormtype="big_decimal" persistent=true precision="16" scale="14" default="0" hint=""; 

I do not understand accuracy or scale correctly. Using the property above, why will β€œ1” give an error and β€œ2” will be accepted? what should i change to accept "1"

1) -118.27 = error

2) -18.27 = ok

+6
source share
1 answer

Scale means the number of digits to the right of the decimal point. If you have an accuracy of 16 and a scale of 14, you can only have 2 digits for the left decimal point, so

 18.12345678901234 = ok 118.27 = error 

Try:

 precision="16" scale="13" 

This will allow 118.1234567890123, but that is a lot of decimal places. How much do you really need?

 precision="16" scale="4" 

Allow 123456789012.1234

+7
source

Source: https://habr.com/ru/post/918043/


All Articles