User Tools

Site Tools


data-arrays-references

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
data-arrays-references [2018/08/22 02:28]
barryfp
data-arrays-references [2018/12/14 15:12]
barryfp [Primitive types]
Line 40: Line 40:
 Note that string concatenation is achieved by constructing a character array into which the existing and extra character arrays are passed as parameters (see below documentation on arrays). Note that string concatenation is achieved by constructing a character array into which the existing and extra character arrays are passed as parameters (see below documentation on arrays).
  
-Decimal types are declared using the "​dec"​ type:+Decimal types are declared using the "​dec"​ type, and can hold both positive and negative numbers:
  
 ''​dec d = 0.5''​ ''​dec d = 0.5''​
Line 46: Line 46:
 If the left hand side of an assignment is a decimal type and the right hand side is an integer, the integer is automatically converted up to its decimal equivalent. If the left hand side is an integer type and the right hand side is a decimal, the integer part of the decimal number is taken and assigned to the integer (i.e. discarding the fractional part). If the left hand side of an assignment is a decimal type and the right hand side is an integer, the integer is automatically converted up to its decimal equivalent. If the left hand side is an integer type and the right hand side is a decimal, the integer part of the decimal number is taken and assigned to the integer (i.e. discarding the fractional part).
  
-The size of the ''​dec''​ type is twice the size of the host machine'​s address width; on 32bit machines it is therefore an 8 byte value, and on 64bit machines it is a 16 byte value. +The size of the ''​dec''​ type is twice the size of the host machine'​s address width; on 32bit machines it is therefore an 8 byte value, and on 64bit machines it is a 16 byte value. ​As with int typesthere are the same set of sizes of dec type, from dec1 to dec512 ​-- however for dec types the actual size in memory is twice that of the named size. We use the same numerical identifiers ​as int in the type names because a dec type of a given bit width is able to store (at least) the same maximum value as an int type of the same named bit widthA dec1 can therefore store a number of at least 255.
- +
-Arithmetically, the ''​dec'' ​type is a fixed-point base 10 number ​in which the number ​of digits after the point is calculated ​as: (number of digits contained ​in the largest unsigned decimal integer that can be represented in half the bit-width of the ''​dec''​ type) - 1For 16-byte ''​dec''​ type, therefore, the number of digits after the point is 19. +
 ====== Data types ====== ====== Data types ======
  
Line 157: Line 154:
 </​code>​ </​code>​
  
-You can query at runtime whether or not a given type has a particular sub-type identity by using the ''​hastype''​ operator. As an example, consider a function that receives an Object instance as a parameter. We can then use ''​hastype''​ to determine whether or not this Object is actually ​a File type and then call File operations on it:+You can query at runtime whether or not a given type has a particular sub-type identity by using the ''​hastype''​ operator. As an example, consider a function that receives an Object instance as a parameter. We can then use ''​hastype''​ to determine whether or not this Object is structurally equivalent to a File type and then call File operations on it:
  
 <code d> <code d>
data-arrays-references.txt · Last modified: 2019/05/28 10:45 by barryfp