data-arrays-references

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

Both sides previous revision Previous revision | |||

data-arrays-references [2018/08/22 02:29] barryfp [Inter-type assigns and hastype] |
data-arrays-references [2018/12/14 15:12] (current) 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 types, there 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 width. A 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) - 1. For a 16-byte ''dec'' type, therefore, the number of digits after the point is 19. | + | |

====== Data types ====== | ====== Data types ====== | ||

data-arrays-references.1534919347.txt.gz · Last modified: 2018/08/22 02:29 by barryfp