# About number ... The accuracy problem

Source: Internet
Author: User

One

When the precision of a number is set to numbers (3,2), then the number of digits he can enter can only be 3-2 = 1 bits, and if the decimal place is not enough, it will be filled with 0, and the rounding that is exceeded retains 3 decimal places.

sql> INSERT INTO T_te (NUM1) values (45.67882);
Insert into T_te (NUM1) VALUES (45.67882)
ORA-01438: Value greater than the allowable precision specified for this column

sql> INSERT INTO T_te (NUM1) VALUES (12.3);
Insert into T_te (NUM1) VALUES (12.3)
ORA-01438: Value greater than the allowable precision specified for this column

sql> INSERT INTO T_te (NUM1) values (1.3);
1 row inserted

Sql> select Num1 from T_te;
NUM1
-----
1.30

Two
When the precision of a number is set to numbers (3,0), the number of integers that can be entered is only less than 5 bits, and the fractional parts are rounded, leaving only integers. In this case, the system defaults to number (3) when defining the data type of the column.

sql> INSERT INTO T_te (num2) values (123.45);
1 row inserted

Sql> select num2 from T_te;
NUM2
----
123

sql> INSERT INTO T_te (num2) values (1234.45);
Insert into T_te (num2) VALUES (1234.45)
ORA-01438: Value greater than the allowable precision specified for this column

sql> INSERT INTO T_te (num2) values (1.45);
1 row inserted

Sql> select num2 from T_te;
NUM2
----
123
1

sql> INSERT INTO T_te (num2) values (1.89);
1 row inserted

Sql> select num2 from T_te;
NUM2
----
123
1
2

Three
When the precision of a number (2,3) is determined, then the number can be entered can only be decimal, and only after the decimal point (3-2=1) decimal place, the integer digits cannot have numbers.

sql> INSERT INTO T_te (NUM3) values (1.89);
Insert into T_te (NUM3) VALUES (1.89)
ORA-01438: Value greater than the allowable precision specified for this column

sql> INSERT INTO T_te (NUM3) values (0.89);
Insert into T_te (NUM3) VALUES (0.89)
ORA-01438: Value greater than the allowable precision specified for this column

sql> INSERT INTO T_te (num3) values (0.089);
1 row inserted

Sql> select num3 from T_te;
NUM3
----
0.08

Four

When the precision of a number is set to numbers (3,-2), the number entered can be any one integer part less than 5 ((-2)) bit, fractional part random number, but the system will be rounded to keep the hundred display.

sql> INSERT INTO T_te (NUM4) values (12.3456);
1 row inserted

sql> INSERT INTO T_te (NUM4) values (122.3456);
1 row inserted

sql> INSERT INTO T_te (NUM4) values (1222.3456);
1 row inserted

sql> INSERT INTO T_te (NUM4) values (122234253524.3456);
Insert into T_te (NUM4) VALUES (122234253524.3456)
ORA-01438: Value greater than the allowable precision specified for this column

sql> INSERT INTO T_te (NUM4) values (12223.3456);
1 row inserted

sql> INSERT INTO T_te (NUM4) values (122236.3456);
Insert into T_te (NUM4) VALUES (122236.3456)
ORA-01438: Value greater than the allowable precision specified for this column

Sql> select Num4 from T_te;
NUM4
-----
0
100
1200
12200

Five
When the precision of a number is set to 2,-3, the number can be entered as long as the integer part does not exceed 5 (--(-3)) bit, no error is made, and the decimal digit is rounded directly. The system displays only the whole number of parts

sql> INSERT INTO T_te (NUM5) values (12345);
1 row inserted

sql> INSERT INTO T_te (NUM5) values (12345723);
Insert into T_te (NUM5) VALUES (12345723)
ORA-01438: Value greater than the allowable precision specified for this column

sql> INSERT INTO T_te (NUM5) values (123456);
Insert into T_te (NUM5) VALUES (123456)
ORA-01438: Value greater than the allowable precision specified for this column

sql> INSERT INTO T_te (NUM5) values (12345.345678);
1 row inserted

Sql> select NUM5 from T_te;
NUM5
----
12000
12000

About number ... The accuracy problem

Related Keywords:

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.