📅  最后修改于: 2021-01-01 04:32:18             🧑  作者: Mango
F#主要支持4种类型的数据类型。
Types | Data Types |
---|---|
Primitive data types | char, byte, bool, int, float |
Derived data types | class, array, list, records, sequence |
Enumeration | enum |
Unit type | it is used if other data types are not specified. |
基本数据类型基于整数和浮点类型。 F#支持有符号和无符号字面量。
Data Types | Description | Range | Suffix Or Prefix |
---|---|---|---|
bool | Possible values are true and false | NA | |
sbyte | signed 8-bit integer | -128 to 127 | y |
byte | unsigned 8-bit natural number | 0 to 255 | uy |
int16 | signed 16-bit integer | -32768 to 32767 | s |
uint16 | unsigned 16-bit natural number | 0 to 65535 | us |
int or int32 | signed 32-bit integer | -231+1 to 231-1 | us |
uint or uint32 | unsigned 32-bit natural number | 0 to 4,294,967,295 | u or ui |
nativeint | Native pointer as a signed natural number | n | |
unativeint | native pointer as an unsigned natural number | un | |
int64 | signed 64-bit integer | -263+1 to 0 to 263-1 | un |
uint64 | unsigned 64-bit natural number | 0 to 263-1 | ul |
single or float32 | 32-bit floating point number | F or f | |
float; double | 64-bit floating point number | none | |
bigint | integer not limited to 64-bit representation | l | |
decimal | fractional number represented as a fixed point or rational number | M or m | |
Char | Unicode character | none | |
String | Unicode string | None | |
Byte | Ascii character | B | |
Byte[] | Ascii string | B | |
unit | Indicates the absence of an actual value. The type has only one formal value which is denoted (). The unit value, (), is often used as a placeholder where a value is needed but no real value is available. | ||
Void | Indicates no type or value. | ||
String or byte[] | Verbatim string | @prefix |
F#派生的数据类型是类,数组,结构等。我们将在后面讨论。
我们将在下一章中讨论枚举。