Marcel van Lohuizen | 75cb003 | 2019-01-11 12:10:48 +0100 | [diff] [blame] | 1 | [TOC](Readme.md) [Prev](ranges.md) [Next](lists.md) |
| 2 | |
Marcel van Lohuizen | 3e592b4 | 2019-01-11 20:31:29 +0100 | [diff] [blame] | 3 | _Types ~~and~~ are Values_ |
Marcel van Lohuizen | af0932f | 2019-01-11 13:03:56 +0100 | [diff] [blame] | 4 | |
Marcel van Lohuizen | 75cb003 | 2019-01-11 12:10:48 +0100 | [diff] [blame] | 5 | # Predefined Ranges |
| 6 | |
Marcel van Lohuizen | 3eb3a3c | 2019-01-11 12:39:52 +0100 | [diff] [blame] | 7 | CUE numbers have arbitrary precision. |
Marcel van Lohuizen | 75cb003 | 2019-01-11 12:10:48 +0100 | [diff] [blame] | 8 | Also there is no unsigned integer type. |
| 9 | |
| 10 | CUE defines the following predefined identifiers to restrict the ranges of |
| 11 | integers to common values. |
| 12 | |
| 13 | ``` |
| 14 | uint 0..int |
| 15 | uint8 0..255 |
| 16 | int8 -128..127 |
| 17 | uint16 0..65536 |
| 18 | int16 -32_768...32_767 |
| 19 | rune 0..0x10FFFF |
| 20 | uint32 0..4_294_967_296 |
| 21 | int32 -2_147_483_648..2_147_483_647 |
| 22 | uint64 0..18_446_744_073_709_551_615 |
| 23 | int64 -9_223_372_036_854_775_808..9_223_372_036_854_775_807 |
| 24 | int128 -170_141_183_460_469_231_731_687_303_715_884_105_728.. |
| 25 | 170_141_183_460_469_231_731_687_303_715_884_105_727 |
| 26 | uint128 0..340_282_366_920_938_463_463_374_607_431_768_211_455 |
| 27 | ``` |
| 28 | |
| 29 | <!-- CUE editor --> |
| 30 | ``` |
| 31 | positive: uint |
| 32 | byte: uint8 |
| 33 | word: int32 |
| 34 | |
| 35 | { |
| 36 | a: positive & -1 |
| 37 | b: byte & 128 |
| 38 | c: word & 2_000_000_000 |
| 39 | } |
| 40 | ``` |
| 41 | |
| 42 | <!-- result --> |
| 43 | ``` |
| 44 | a: _|_ |
| 45 | b: 128 |
| 46 | c: 2000000000 |
| 47 | ``` |