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 - typefunction [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- typewill return- -7hfor a long integer (the- hbeing 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.- typewill 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: