Javatpoint Logo
Javatpoint Logo

Data Types in F#

F# supports mainly 4 types of data types.

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.

1) F# Primitive data types

Primitive data types are integral and floating type based. F# supports both signed and unsigned literals.

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

2) F# Derived Data Types

F# Derived data types are classes, arrays, structures etc. We will discuss about these later.

3) F# Enumeration

We will discuss about enumeration in next chapters.

Next TopicF# Unit Type

Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


B.Tech / MCA