In Delphi, you can use the following types to store integer values
- Byte an unsigned 8-bit integer, ranging from 0 to 255
- ShortInt a signed 8-bit integer, ranging from -128 to 127
- Word an unsigned 16-bit integer, ranging from 0 to 65,535
- SmallInt a signed 16-bit integer, ranging from -32,768 to 32,767
- LongWord an unsigned 32-bit integer, ranging from 0 to 4,294,967,295
- Integer a signed 32-bit integer, ranging from -2,147,483,648 to 2,147,483,647
- Int64 a signed 64-bit integer, ranging from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
- To declare a variable of one of these types, you can use the following syntax
1 2 3 4 |
var i: Integer; lw: LongWord; i64: Int64; |
You can also use the Single type to store single-precision floating-point values, and the Double type to store double-precision floating-point values. To declare a variable of one of these types, you can use the following syntax
1 2 3 |
var f: Single; d: Double; |
You can assign values to these variables using standard assignment statements, like this
1 2 3 |
i := 10; f := 3.14; d := 1.23456789; |
You can also perform arithmetic operations on these variables, like this
1 2 3 |
i := 10 + 5; f := 3.14 / 2.0; d := 1.23456789 * 3.0; |
Note that you should be careful when performing arithmetic operations with floating-point values, as they are not always represented exactly in the computer’s memory and may introduce small errors in your calculations.
Leave a Reply