Encounter double number too large, turn string into scientific counting method

Source: Internet
Author: User

Problem:

 In Java, when the double number is too large, the string is turned out to be a representation of the scientific notation.

Summarize:

  1. The project is stored with a mapping relationship between the type of Mysql,mysql and the Java type, which was previously of little concern. Now summarize:

  

Type name Display length Database type Java type JDBC Type index (int) Describe
VARCHAR L+n VARCHAR Java.lang.String 12
CHAR N CHAR Java.lang.String 1
Blob L+n Blob Java.lang.byte[] -4
TEXT 65535 VARCHAR Java.lang.String -1
INTEGER 4 INTEGER UNSIGNED Java.lang.Long 4
TINYINT 3 TINYINT UNSIGNED Java.lang.Integer -6
SMALLINT 5 SMALLINT UNSIGNED Java.lang.Integer 5
Mediumint 8 Mediumint UNSIGNED Java.lang.Integer 4
BIT 1 BIT Java.lang.Boolean -7
BIGINT 20 BIGINT UNSIGNED Java.math.BigInteger -5
FLOAT 4+8 FLOAT Java.lang.Float 7
DOUBLE 22 DOUBLE Java.lang.Double 8
DECIMAL 11 DECIMAL Java.math.BigDecimal 3
BOOLEAN 1 With tinyint
Id 11 PK (INTEGER UNSIGNED) Java.lang.Long 4
DATE 10 DATE Java.sql.Date 91
Time 8 Time Java.sql.Time 92
Datetime 19 Datetime Java.sql.Timestamp 93
TIMESTAMP 19 TIMESTAMP Java.sql.Timestamp 93
Year 4 Year Java.sql.Date 91






2. for Bolb, generally used for image database storage, the principle is to make the picture into binary, and then do a storage method, in Java corresponding to the byte[] array.

3. For the Boolen type, in the MySQL database, the individual thinks that the use of the int type is better, the bit operation is not very convenient, especially in the project with Web page development, represents 0/1, corresponding to the Java type of integer is better.

4. The problem I encountered this time, I use the solution is the MySQL end with a decimal to store, and then the Java side with BigDecimal to receive,

Involves some of the uses of decimal:

    • decimal Turn int

BigDecimal a=New BigDecimal (12.88); int

    • int to decimal
New BigDecimal (int val);

    

  

Encounter double number too large, turn string into scientific counting method

Contact Us

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.