integer
本頁內容尚未翻譯。
cfamily.Rank
Section titled “cfamily.Rank”data RankThe integer conversion rank (C11 6.3.1.1p1): bool < char < short < int < long < long long.
cfamily.Rank.order
Section titled “cfamily.Rank.order”def Rank.order (r : Rank) : NatThe order of a rank, from 0 for bool.
cfamily.Rank.belowNormal
Section titled “cfamily.Rank.belowNormal”def Rank.belowNormal (r : Rank) : BoolWhether a rank is below int’s: such types are promoted.
cfamily.Rank.width
Section titled “cfamily.Rank.width”def Rank.width (p : Platform) (r : Rank) : NatThe width of a rank’s type on a platform (bool’s is 1).
cfamily.IntegerType
Section titled “cfamily.IntegerType”record IntegerTypeAn integer type: signedness, rank, width in bits, and whether it is plain char.
cfamily.Platform
Section titled “cfamily.Platform”record PlatformA platform’s integer and pointer widths, whether plain char is signed, and the greatest alignment a scalar has in bytes (a scalar is aligned to its size up to it).
cfamily.Platform.aligned
Section titled “cfamily.Platform.aligned”def Platform.aligned (p : Platform) (bytes : Nat) : NatThe alignment of a scalar of a size in bytes on a platform.
cfamily.Platform.lp64
Section titled “cfamily.Platform.lp64”def Platform.lp64 : PlatformLP64, the usual desktop and server platform (Linux and macOS; char signed as on x86-64).
cfamily.Platform.avr
Section titled “cfamily.Platform.avr”def Platform.avr : PlatformAVR, the Arduino Uno’s platform: 16-bit int and pointers, 32-bit long; every type aligned to 1 byte (avr-gcc’s ABI: no padding).
cfamily.Platform.esp
Section titled “cfamily.Platform.esp”def Platform.esp : PlatformESP32 and ESP8266 (the Xtensa and RISC-V GCC): 32-bit int, long and pointers, plain char unsigned.
cfamily.IntegerType.boolean
Section titled “cfamily.IntegerType.boolean”def IntegerType.boolean : IntegerTypebool.
cfamily.IntegerType.signedChar
Section titled “cfamily.IntegerType.signedChar”def IntegerType.signedChar : IntegerTypesigned char.
cfamily.IntegerType.unsignedChar
Section titled “cfamily.IntegerType.unsignedChar”def IntegerType.unsignedChar : IntegerTypeunsigned char.
cfamily.IntegerType.char
Section titled “cfamily.IntegerType.char”def IntegerType.char (p : Platform) : IntegerTypePlain char: signed or not as the platform says.
cfamily.IntegerType.short
Section titled “cfamily.IntegerType.short”def IntegerType.short (p : Platform) : IntegerTypeshort.
cfamily.IntegerType.unsignedShort
Section titled “cfamily.IntegerType.unsignedShort”def IntegerType.unsignedShort (p : Platform) : IntegerTypeunsigned short.
cfamily.IntegerType.int
Section titled “cfamily.IntegerType.int”def IntegerType.int (p : Platform) : IntegerTypeint.
cfamily.IntegerType.unsignedInt
Section titled “cfamily.IntegerType.unsignedInt”def IntegerType.unsignedInt (p : Platform) : IntegerTypeunsigned int.
cfamily.IntegerType.long
Section titled “cfamily.IntegerType.long”def IntegerType.long (p : Platform) : IntegerTypelong.
cfamily.IntegerType.unsignedLong
Section titled “cfamily.IntegerType.unsignedLong”def IntegerType.unsignedLong (p : Platform) : IntegerTypeunsigned long.
cfamily.IntegerType.longLong
Section titled “cfamily.IntegerType.longLong”def IntegerType.longLong (p : Platform) : IntegerTypelong long.
cfamily.IntegerType.unsignedLongLong
Section titled “cfamily.IntegerType.unsignedLongLong”def IntegerType.unsignedLongLong (p : Platform) : IntegerTypeunsigned long long.
cfamily.IntegerType.sameType
Section titled “cfamily.IntegerType.sameType”def IntegerType.sameType (a : IntegerType) (b : IntegerType) : BoolWhether two types are the same type (plain char differs from both signed and unsigned char).
cfamily.IntegerType.minimum
Section titled “cfamily.IntegerType.minimum”def IntegerType.minimum (t : IntegerType) : IntThe least value of a type.
cfamily.IntegerType.maximum
Section titled “cfamily.IntegerType.maximum”def IntegerType.maximum (t : IntegerType) : IntThe greatest value of a type.
cfamily.IntegerType.inRange
Section titled “cfamily.IntegerType.inRange”def IntegerType.inRange (t : IntegerType) (v : Int) : BoolWhether a value is in a type’s range.
cfamily.IntegerType.covers
Section titled “cfamily.IntegerType.covers”def IntegerType.covers (u : IntegerType) (t : IntegerType) : BoolWhether u can represent every value of t; compares widths and signedness only, so no 2^width is built.
cfamily.IntegerType.promote
Section titled “cfamily.IntegerType.promote”def IntegerType.promote (p : Platform) (t : IntegerType) : IntegerTypeThe integer promotions: a type ranked below int, or a bit-field narrower than its type that fits in int’s width, becomes int if int covers it, else unsigned int (C11 6.3.1.1p2).
cfamily.IntegerType.unsignedVersion
Section titled “cfamily.IntegerType.unsignedVersion”def IntegerType.unsignedVersion (t : IntegerType) : IntegerTypeThe unsigned type of the same rank and width.
cfamily.IntegerType.firstOfWidth
Section titled “cfamily.IntegerType.firstOfWidth”def IntegerType.firstOfWidth (w : Nat) (ts : List IntegerType) : Option IntegerTypeThe first of some types that is w bits wide, if any.
cfamily.IntegerType.difference
Section titled “cfamily.IntegerType.difference”def IntegerType.difference (p : Platform) : IntegerTypeptrdiff_t and intptr_t: the first of int, long and long long as wide as a pointer (long on LP64’s glibc, int in
AVR libc and in the ESP chips’ newlib).
cfamily.IntegerType.size
Section titled “cfamily.IntegerType.size”def IntegerType.size (p : Platform) : IntegerTypesize_t and uintptr_t: the unsigned type of ptrdiff_t’s rank.
cfamily.IntegerType.maximal
Section titled “cfamily.IntegerType.maximal”def IntegerType.maximal (p : Platform) : IntegerTypeintmax_t: long when it is as wide as long long (glibc), else long long.
cfamily.IntegerType.unsignedMaximal
Section titled “cfamily.IntegerType.unsignedMaximal”def IntegerType.unsignedMaximal (p : Platform) : IntegerTypeuintmax_t: the unsigned type of intmax_t’s rank.
cfamily.IntegerType.exactly
Section titled “cfamily.IntegerType.exactly”def IntegerType.exactly (p : Platform) (w : Nat) : Option IntegerTypeintN_t (and int_leastN_t): the first of signed char, int, short, long and long long that is w bits wide (short
for 16 bits and long for 64 on LP64’s glibc; int for 16 bits and long for 32 in AVR libc).
cfamily.IntegerType.commonMixed
Section titled “cfamily.IntegerType.commonMixed”def IntegerType.commonMixed (s : IntegerType) (u : IntegerType) : IntegerTypeThe common type of a signed and an unsigned promoted type.
cfamily.IntegerType.commonPromoted
Section titled “cfamily.IntegerType.commonPromoted”def IntegerType.commonPromoted (a : IntegerType) (b : IntegerType) : IntegerTypeThe common type of two promoted types: the higher rank if their signedness agrees, else by commonMixed.
cfamily.IntegerType.common
Section titled “cfamily.IntegerType.common”def IntegerType.common (p : Platform) (a : IntegerType) (b : IntegerType) : IntegerTypeThe usual arithmetic conversions on two integer types: promote both, then take the common type.
cfamily.IntegerType.convert
Section titled “cfamily.IntegerType.convert”def IntegerType.convert (t : IntegerType) (v : Int) : IntAny integer converted to the type: whether it is nonzero for bool, else modulo 2^width (two’s complement if signed).