Guru's Verification engine ensures consistency, confidence, and trust in the knowledge your organization shares. Learn more.

q/kdb+ | Data types

q uses a concise system for representing types. Each data type has both a character and a number (short int) associated with it, as documented in the type table [1].

Some starting notes:

  • the type function [2] will return the number associated with the data type, as a short int. For example, the number associated with atomic long integers is -7, so type will return -7h for a long integer (the h being the type of the returned number, which is a short)

  • the number listed in that table (column n) is the absolute value of what's returned by type. type will return the negative version of the number if the type of the data is atomic

  • you can convert between different types using the $ infix function [3] (see example below)

Examples:

10j                / atomic 10 in `j` type (i.e. long integer)10                 / also a long int (ints are long by default)10h                / atomic 10 in `h` type (i.e. short integer)type 10j           / -7h, representing an atomic long int10f                / 10 in `f` type (float)type 10f           / -9h, representing a float(10 11 12)         / list of long intstype (10 11 12)    / 7h, representing a non-atomic long int (contrast `type 10j`)9h$10j             / converts to 10f (note usage of positive `9h` as the first argument)

Resources:

You must have Author or Collection Owner permission to create Guru Cards. Contact your team's Guru admins to use this template.