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