Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the data types in the database?

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article is to share with you about the data types in the database. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Data types are: 1, integer type [byte, short, int, long]; 2, floating point type [float, double]; 3, character type char;4, Boolean type boolean.

The data types are:

1) four integer types (byte, short, int, long):

Byte:8 bit, used to represent the smallest unit of data, such as data in a file,-128 to 127

Short:16 bit, rarely used,-32768 ~ 32767

Int:32 bit, most commonly used,-2 ^ 31-1 ~ 2 ^ 31 (2.1 billion)

Long:64 bit, second commonly used

Note: int item5; / 5 is called a direct quantity (or literal quantity), that is, a constant written directly.

The whole numeric area is int by default, so add L or l after the defined long data.

Variables less than 32 digits are calculated according to the int result.

Strong converters take precedence over mathematical operators. See examples in constants and variables.

2) two types of floating point numbers (float, double):

Float:32 bit, suffix F or fjore 1-bit symbol bit, 8-bit index, 23-bit effective Mantissa.

Double:64 bit, most commonly used, suffix D or dline 1 symbol bit, 11-bit index, 52-bit valid tail

Note:

Binary floating point number: 1010100010 "101010001.0" 2 "10101000.10 * 2 ^ 10 (power 2) = 1010100.010 * 2 ^ 11 (power 3) =. 1010100010 * 2 ^ 1010 (to the 10th power)

Mantissa:. 1010100010

Index: 1010

Cardinality: 2

Floating-point numeric float is double by default, so adding F or fumbdouble after the defined float data can not write a suffix, but in decimal calculation, the precision of writing D or X.X doubles is not as high as long, and the significant digits (Mantissa) are short.

The range of float is larger than long index can be very large.

Floating-point numbers are imprecise and cannot be accurately compared.

3) A character type (char):

The char:16 bit, which is an integer type, 1 character (which can be a Chinese character) enclosed in single quotation marks, is represented by a Unicode code, 0 ~ 2 ^ 16-1 (65535).

Note: cannot be 0 characters.

Escape character:\ nnewline\ r carriage return\ t Tab character\ "double quotation marks\\ indicates a\"

Two characters char in the middle with "+" connection, the internal character into the int type, and then add operation, the essence of char is the number! Binary, when displayed, is displayed as characters after "processing".

4) A Boolean type (boolean): true true and false false.

5) Type conversion:

Char-- > automatic conversion: byte-- > short-- > int-- > long-- > float-- > double

Forced conversion: ① loses precision and produces errors, and all digits after the decimal point are discarded. ② is easy to exceed the value range.

6) memory:

8 bits: Byte (byte type)

16 bits: short (short integer), char (character type)

32-bit: int (integer), float (single precision / floating point)

64-bit: long (long integer), double (double precision)

Last one: boolean Boolean type

Thank you for reading! This is the end of the article on "how many data types are in the database". I hope the above content can be of some help to you, so that you can learn more knowledge. If you think the article is good, you can share it for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report