Home > Common Problem > body text

The data type is

(*-*)浩
Release: 2019-06-04 15:40:10
Original
3480 people have browsed it

The definition of a data type in a data structure is a set of values ​​with the same properties and a set of operations defined on this set of values.

The data type is

#Variables are places used to store values. They have names and data types. The data type of a variable determines how the bits representing those values ​​are stored in the computer's memory. You can also specify the data type of a variable when declaring it. All variables have a data type to determine what kind of data can be stored.

Data types include primitive types, tuples, record units, algebraic data types, abstract data types, reference types and function types.

Definition(Recommended learning: PHP video tutorial)

In computers, data is represented by bits (0 or 1). The smallest addressing unit of data is called a byte (usually eight bits). The unit of machine code instruction processing is called the word length. Most instruction interpretations of word lengths are mainly based on binary. For example, a 32-bit word length can represent an unsigned integer value from 0 to 2 to the power of 32 minus 1, or it can represent an unsigned integer value from negative 2 to 32. A signed integer value raised to the power 2 raised to the 32nd power minus 1. Special arithmetic instructions exist that use different interpretations of the bits in the word length as floating point numbers.

The emergence of data types is to divide data into data with different memory sizes. When programming, you need to apply for large memory only when you need to use big data, so that you can make full use of the memory. For example, if a fat person has to sleep in a double bed, give him a double bed, while a thin person can get a single bed.

According to the default regulations, if the data type is not specified in the declaration, the data type of the variable is Variant. The Variant data type is like a chameleon—it can represent different data types in different situations. When you specify a variable as a Variant variable, you do not have to convert between data types; Visual Basic automatically completes the necessary conversions.

However, if you know that a variable always stores data of a specific type, and you declare a variable of that specific type, Visual Basic can handle this data more efficiently. For example, a variable that stores a person's name is best represented as a String data type because names always consist of characters.

In addition to variables, data types are also used in other situations. When assigning a value to a property, the value has a data type; the parameters of the function also have a data type. In fact, in Visual Basic, everything that has to do with data has to do with data types.

Declaring Variables

Before using a non-Variant variable, you must declare the variable as As type using a Private, Public, Dim, or Static statement. For example, the following statements declare variables of type Integer, Double, String and Currency respectively:

PrivateIAsInteger
DimAmtAsDouble
StaticYourNameAsString
PublicBillsPaidAsCurrency
Copy after login

One declaration statement can combine multiple declarations, please see the following statement

PrivateIAsInteger,AmtAsDouble
PrivateYourNameAsString,BillsPaidAsCurrency
PrivateTest,Amount,JAsInteger
Copy after login

'Note, Here Test and Amount are Variant data types, and only J is Integer data type

Note that if no data type is provided, the specified variable is the default type. As explained in the comments in the above example, if experience with other programming languages ​​makes people feel that all variables in the same declaration statement have the same specified data type (Integer in this example), then the results here may be confusing. Feel fresh.

For more PHP-related technical articles, please visit the PHP Graphic Tutorial column to learn!

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!