# Literals

It is a constant written directly in the code.

Constant

int literal

long literal

real literal

string literal

bool literal

## Constant

Literals are constants that are written directly in the code.

int i = 10;

string s = "literal";

The value is described directly like above, the instance of the class corresponding to the value is allocated in the memory, and its address is returned.

Literals are:

int literal

long literal

real literal

string literal

bool literal

A literal returns an instance. Therefore, class members can be called via a literal.

int length = "ggggg".Length; // The length of the string.

## int literal

An int literal is a positive integer written directly in the code.

The range is from 0 to the maximum of the int class: 2,147,483,647.

There is no negative literal. If you need a negative number, use the unary minus operator.

An exception is thrown if the int literal exceeds the above range.

Formats are:

A numeric value that a first letter is a digit other than zero and followed by zero or more digits.

123

A number that the above is followed by an uppercase I.

123I

A single zero.

0

## long literal

An long literal is a positive integer written directly in the code.

The range is from 0 to the maximum of the long class: 9,223,372,036,854,775,807.

There is no negative literal. If you need a negative number, use the unary minus operator.

An exception is thrown if the long literal exceeds the above range.

Formats are:

A numeric value that a first letter is a digit other than zero and followed by zero or more digits and followed by an upper case L.

123L

A numeric value that a first letter is zero and followed by an upper case L.

0L

## real literal

An real literal is a positive real number written directly in the code.

The range is roughly from +5.0e−324 to +1.7e308.

There is no negative literal. If you need a negative number, use the unary minus operator.

The real literal is evaluated as positive infinity if bigger than the maximum value and as 0 if smaller than the minimum value.

Formats are:

A numeric value that a first letter is a digit other than zero and followed by zero or more digits and followed by dot and followed by one or more digits.

123.005

A numeric value that a first letter is zero and followed by dot and followed by one or more digits.

0.005

A numeric value that a first letter is dot and followed by one or more digits.

.005

Zero in the real literal is following:

0.0

## string literal

A string literal is a string that repeats characters other than double quotes that surrounded by double quotes.

"Other than double quotes"

## bool literal

A bool literal is a boolean value written directly in a code. The true and false keyword are used to represent bool literals.

true

false