The type conversion of Delphi

Source: Internet
Author: User

Delphi is a strongly typed language. In VC, the assignment character uses ″=″, for example X=1, to the Delphi assignment becomes ″:=″, for example X:=1. From the value of the symbol ″:=″ without ″=″, on the looming Delphi to type matching requirements of strict, that is, the right type of assignment must be consistent with the left.

Accustomed to VB or VC programmers, the initial use of Delphi, slightly inattentive, there will be type mismatch errors. For beginners, type conversion is also the focus and difficulty of learning Delphi, for this Benwent to Delphi type conversion to do a summary, for the reference of readers.

Type conversions of one or more numbers

Converts the type of an expression from one type to another, and the resulting value truncates or expands the original value, and the sign bit remains unchanged. For example:

Type conversions of numbers

Example

Converts characters to integers

Integer (' A ')

Integer conversion to character

Char (48)

Integer converts to 1-byte logical type

Boolean (0)

Integer converts to 2-byte logical type

Wordbool (0)

Integer converts to 4-byte logical type

Longbool (0)

Integer converted to 10-in-Pascal string

CAPTION:=INTTOSTR (15)

Integer converted to 16-in-Pascal 4-bit string

Caption:=inttohex (15,4)

Address conversion to Long integer number

Longint (@Buffer)

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.