search
HomeCommon ProblemWhat are the data types?

What are the data types?

Jan 28, 2021 pm 05:16 PM
type of data

Data types include: 1. Integer type [byte, short, int, long]; 2. Floating point type [float, double]; 3. Character type char; 4. Boolean type boolean.

The operating environment of this article: Windows10 Home Chinese version, Acer S40-51 computer.

Free recommendation: Programming video course

The data types are:

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

  • byte: 8 bits, used to represent the smallest data unit, such as data in a file, -128~127

  • short: 16 bits, rarely used, -32768 ~ 32767

  • int: 32 bits, most commonly used, -2^31-1~2^31 (2.1 billion)

  • long: 64 bits, commonly used

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

Integer literals are of type int by default, so add L or l after the defined long data.​

Variables less than 32 digits are calculated as int results.​

Forced operators have higher priority than mathematical operators. See Constants and Variables for examples.

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

float: 32 bits, suffix F or f, 1 sign bit, 8-bit exponent, 23 valid mantissas.

double: 64 bits, most commonly used, suffix D or d, 1 sign bit, 11 bits of exponent, 52 bits of effective tail

Notes:

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

Mantissa: . 101010001 0

Exponent: 1010

Base: 2

Floating point numeric values ​​are of double type by default, so add F or f after the defined float type data; double type is not required Write the suffix, but be sure to write D or X. The range of

float is larger than long and the exponent can be very large.​

Floating point numbers are inexact, and floating point numbers cannot be accurately compared.

3) A character type (char):

char: 16 bits, an integer type, 1 character enclosed in single quotes (can be a Chinese characters), using Unicode code to represent characters, 0~2^16-1 (65535).​

Note: Cannot be 0 characters.

Escape characters: \n Line feed \r Carriage return \t Tab character \" Double quotation mark \\ represents a \

Two characters char are connected with " " in the middle, and the characters are converted internally first into int type, and then perform addition operation, char is essentially a number! Binary, when displayed, it is "processed" and displayed as characters.

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

5) Type conversion:

char--> Automatic conversion: byte-->short-->int -->long-->float-->double                                                                                                                                                                                                                                          through

##6) Memory:

8 bits: Byte (byte type) 16 bits: short (short integer type), 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

Related free learning recommendations:

php programming(Video)

The above is the detailed content of What are the data types?. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Will R.E.P.O. Have Crossplay?
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Atom editor mac version download

Atom editor mac version download

The most popular open source editor