Type ‣ Comptime int ᴾᴴᴾ - chung-leong/zigar GitHub Wiki

JavaScript | PHP


Comptime int is the type for integer literals in the Zig language.

pub const width = 4;

In the above statement, 4 is comptime_int. Because width doesn't have a type specifier, it gets the type from right side. Hence it too is comptime_int.

Comptime integers are represented as either int or GMP depending on whether their values can fit within a 64-bit integer. Because int in PHP is always signed, a positive integer requiring all 64 bits will end up negative:

pub const base = 0x0000_FFFF_FFFF_FFFF;
pub const offset = 16;
<?php

$m = zigar_use(__DIR__ . '/comptime-int-example-2.zig');

echo $m->number;
-1

Types | Comptime float