
A GUID (globally unique identifier) is a 16-byte binary value that is unique across time and space (well, nearly so).

q)0x2aĪs with boolean, a byte participates in arithmetic via type promotion to signed int. Upper or lower case can be used for the alpha hex digits but lower case is customary. The byte type uses one byte to store an unsigned 8-bit value and is denoted by the leading type indicator 0x followed by two hexadecimal digits. The ability of booleans to participate in arithmetic can be useful in eliminating conditionals. For example, the following yields an integer. q)0bīinary values are implicitly promoted to unsigned integers when participating in arithmetic expressions or comparisons. There are no keywords for 'true' or 'false', nor are there separate logical operators for booleans. The boolean type uses one byte to store a bit and is denoted by the bit value with the trailing type indicator b. q)f12:1.23456789012īinary data can be represented as bit or byte values. If you issue \P 0 the console will display all 17 decimal digits of the underlying binary representation, although the last digit is unreliable. You can change this by using the \P command (note upper case) to specify a display width up to 16 digits. The q console display defaults to seven decimal digits of accuracy for float and real values by rounding the display in the seventh significant digit, even though more digits are stored. The scientific notation of reals is awkward, given the presence of e both for the exponent and the type indicator. The real type is basically useless in finance since it does not provide enough precision for quantities expressed in currencies such as Yen. A real can hold at least 6 decimal digits of precision. Be mindful that this type is called 'float' in some languages. The real type represents a single-precision, four-byte floating-point number and is denoted by numeric digits containing a decimal point and a trailing type indicator e. The + and leading 0 for a positive exponent are optional. To the right of the e is a two digit signed exponent. Here the e standards for "exponent" – i.e., a power of 10 – and should not be confused with a type indicator. q)3.14159265Ī float can also be specified in scientific notation. Observe that the console shortens the display of floats with no significant digits to the right of the decimal. It is denoted by optionally signed numeric digits with either a decimal point or an optional trailing type indicator f. A float can hold (at least) 15 decimal digits of precision. The float type represents an IEEE standard eight-byte floating-point number, often called "double" in traditional languages. Single- and double-precision floating-point data types are supported. This may be unintuitive in the context of other type promotion, but it will make sense for table columns.
#BASIC DATA UPDATE#
However, for a homogenous list of atoms of "wide" type, should a narrower type be presented for update or append in place, the narrow type will not be automatically promoted and an error will result. Type promotion is performed automatically in arithmetic operations. Observe that the type indicator j is accepted but redundant. It may also have an optional trailing type indicator j indicating it is a long and not another integer type. A literal is identified as a long by the fact that it contains only numeric digits, with an optional leading minus sign, and no decimal point.


In q versions 3.0 and later, the basic integer type is a signed eight-byte integer, called long. Integer data types are ubiquitous in programming. We shall refer to this in subsequent sections. The next table collects the important information about q data types.

They do have special meaning when used as name arguments in some operators, so do not use them as names. – are not reserved in q, so they are not displayed in a special font in this text. The words under the q heading – boolean, short, int, etc.
