Datatypes in SRON
Data types represent the different kinds of values that variables and expressions can hold or represent.
There are 6 datatypes available in SRON:
1. Int :
Represents whole numbers without decimal parts. Examples include 0, 1, -5, 1000. Range of 'Int' is from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.
'Int' keyword is used to declare Int-type variables.
{
name : Main
Int val = 10
val = -155
}
2. Double :
Represents numbers with fractional parts. It can hold upto 15 floating point decimal digits. Examples include 3.14, -0.001, 2.71828. Range of 'Double' is from 2.22507385850720138309023271733240406e-308 to 1.79769313486231570814527423731704357e+308.
'Double' keyword is used to declare Double-type variables.
{
name : Main
Double val = 10.548994
val = -155.1256
}
3. Char :
Represents single characters, such as letters, digits, and symbols. Character data types are used to store individual characters from a character set (e.g., ASCII, Unicode). Examples include A, B, \n , \t, 1, 2 etc.
'Char' keyword is used to declare Char-type variables and single apostrophe (') is used to make a Char-type values.
{
name : Main
Char val = '\n'
val = 'A'
}
4. String :
Represents sequences of characters. Strings are used to store text or sequences of characters, such as words, sentences, or paragraphs.
String-type values can contain only ASCII characters.
'String' keyword is used to declare String-type variables and quote mark (") is used to make a String-type values.
{
name : Main
String val = "Programming is Fun"
val = "Hello, SRON!"
}
5. Bool :
Represents logical values of true or false. Boolean data types are commonly used in conditions and logical operations. Contains only two values 'true' or 'false'.
'Bool' keyword is used to declare Bool-type variables.
{
name : Main
Bool val = true
val = false
}
6. List :
Represents a sequence of all the above data types in a single unit. It can even store a List type in itself also. \
List variables are declared using 'List' keyword and 'List' are declared using Square brackets '[ ]'.
{
name : Main
List val = [1, 123.456, 'A', "SRON", true]
val = ["List", [1,2,3], false, -0.44, 99, Void]
}
7. Collective :
We cannot directly call Collective a datatype because you cannot create its variable. In the internal functioning of SRON, the 'String' and 'List' types are the child types of Collective.
In other words, Collective is a datatype which is able to store more than one value within itself. Like String which can store many characters within itself. List is also a collective type because it can store more than one values within itself.
Last updated