Skip to main content

Number types

Section

Description

TINYINT

TINYINT is a FairCom database field type containing a signed integer number.

SMALLINT

SMALLINT is a FairCom database field type containing a signed integer number.

INTEGER

INTEGER is a FairCom database field type containing a signed integer number.

BIGINT

BIGINT is a FairCom database field type containing a signed integer number.

ID

Tables created by the JSON DB API have an identifier (ID) field known as "id" that uniquely identifies each record.

NUMBER

NUMERIC is a FairCom database field type containing a signed decimal number.

MONEY

MONEY is a FairCom database field type containing a signed decimal number.

DOUBLE

DOUBLE is a FairCom database field type containing a signed floating point number.

REAL

REAL is a FairCom database field type containing a signed floating point number.

TINYINT is a FairCom database field type containing a signed integer number, such as -128. It is stored in a record as a signed 8-bit integer number with a range from -128 to 127.

Unlike REAL and DOUBLE, TINYINT is a fixed-size decimal number with no loss of precision and no base two rounding errors. FairCom's integer field types include TINYINT (1 byte), SMALLINT (2 bytes), INTEGER (4 bytes), and BIGINT (8 bytes). FairCom's fixed decimal point numbers include NUMERIC and MONEY.

TINYINT's behavior in different APIs:
  • In FairCom's JSON DB API, a TINYINT value is represented in JSON as a number or a string.

  • In FairCom's SQL API, a TINYINT value is submitted and returned as a number using ASCII characters — for example, 127or -128.

  • In FairCom's ISAM and CTDB APIs, a TINYINT value is submitted and returned as a signed 8-bit integer.

SMALLINT is a FairCom database field type containing a signed integer number, such as -32768. It is stored in a record as a signed 16-bit integer number with a range from -32,768 to 32,767.

Unlike REAL and DOUBLE, SMALLINT is a fixed-size decimal number with no loss of precision and no base two rounding errors. FairCom's integer field types include TINYINT (1 byte), SMALLINT (2 bytes), INTEGER (4 bytes), and BIGINT (8 bytes). FairCom's fixed decimal point numbers include NUMERIC and MONEY.

SMALLINT's behavior in different APIs:
  • In FairCom's JSON DB API, a SMALLINT value is represented in JSON as a number or a string.

  • In FairCom's SQL API, a SMALLINT value is submitted and returned as a number using ASCII characters — for example, 123 or -1234.

  • In FairCom's ISAM and CTDB APIs, a SMALLINT value is submitted and returned as a signed 16-bit integer.

INTEGER is a FairCom database field type containing a signed integer number, such as -2147483648. It is stored in a record as a signed 32-bit integer number with a range from -2,147,483,648 to 2,147,483,647.

Unlike REAL and DOUBLE, INTEGER is a fixed-size decimal number with no loss of precision and no base two rounding errors. FairCom's integer field types include TINYINT (1 byte), SMALLINT (2 bytes), INTEGER (4 bytes), and BIGINT (8 bytes). FairCom's fixed decimal point numbers include NUMERIC and MONEY.

INTEGER's behavior in different APIs:
  • In FairCom's JSON DB API, an INTEGER value is represented in JSON as a number or a string.

  • In FairCom's SQL API, an INTEGER value is submitted and returned as a number using ASCII characters — for example, 123 or -123 .

  • In FairCom's ISAM and CTDB APIs, an INTEGER value is submitted and returned as a signed 32-bit integer.

BIGINT is a FairCom database field type containing a signed integer number, such as -9223372036854770000. It is stored in a record as a signed 64-bit integer number with a range from -9,223,372,036,854,770,000 to 9,223,372,036,854,770,000.

Unlike REAL and DOUBLE, BIGINT is a fixed-size decimal number with no loss of precision and no base two rounding errors. FairCom's integer field types include TINYINT (1 byte), SMALLINT (2 bytes), INTEGER (4 bytes), and BIGINT (8 bytes). FairCom's fixed decimal point numbers include NUMERIC and MONEY.

BIGINT's behavior in different APIs:
  • In FairCom's JSON DB API, a BIGINT value is represented in JSON as a number or string.

    The string representation is useful because some JSON parsers and programming languages cannot properly handle BIGINT's larger integer numbers.

  • In FairCom's SQL API, a BIGINT value is submitted and returned as a number using ASCII characters — for example, 123 or -123 .

  • In FairCom's ISAM and CTDB APIs, a BIGINT value is submitted and returned as a signed 64-bit integer.

Tables created by the JSON DB API have an identifier (ID) field known as "id" that uniquely identifies each record. It is the primary key of the record. It is stored as a BIGINT, which is a signed, 64-bit integer. When records are inserted, the FairCom database server automatically populates the value of the "id" field with a unique integer value.

Actions in the JSON DB API use the "id" field for most operations, such as looking up records, updating records, and deleting records. You can reference the "id" field in the JSON DB API using an integer or a string value. Using a string value works well with languages and JSON parsers that do not support numbers as large as 64-bit integers.

Important

Treating the "id" field as an unpredictable integer value is important. Do not assume that sequentially inserted records have sequentially increasing integer values in the "id" field.

NUMBER is a FairCom database field type containing a signed decimal number, such as -12345678900.000000123. It is stored in a record as a signed, fixed-point number that always consumes 19 bytes of storage. Synonyms for NUMBER includes NUMERIC and DECIMAL.

It has up to 32 decimal digits of precision. Its precision and scale are set when a table is created. Precision is the total number of digits allowed in the number. Precision is set using the "length" property, which can be between 1 and 32 digits. Scale is the number of digits to the right of the decimal point. The "scale" property can be set to a number less than or equal to its "length". This allows some, none, or all of the number to be a fraction.

The largest number is ±99,999,999,999,999,999,999,999,999,999,999. The smallest fraction is ±0.000,000,000,000,000,000,000,000,000,000,01.

Unlike REAL and DOUBLE, NUMBER is a fixed-size decimal number with no loss of precision and no base two rounding errors. MONEY works like NUMBER but with a fixed scale of 2 or 4. FairCom's integer field types include TINYINT (1 byte), SMALLINT (2 bytes), INTEGER (4 bytes), and BIGINT (8 bytes).

NUMBER's behavior in different APIs:
  • In FairCom's JSON DB API, a NUMBER value is represented as a JSON number or string.

    The string representation is useful because some JSON parsers and programming languages cannot properly handle numbers with this range.

  • In FairCom's SQL API, a NUMBER value is submitted and returned as a number using ASCII characters — for example, 123.0 or -0.1234.

  • In FairCom's ISAM and CTDB APIs, a NUMBER value is submitted and returned as a FairCom proprietary, 19-byte, binary structure. FairCom provides functions to convert a FairCom NUMBER value into number types used by programming languages.

MONEY is a FairCom database field type containing a signed decimal number, such as -12345678900.0001. It is stored in a record as a signed, fixed-point decimal number with 32 digits of precision. It consumes 19 bytes of storage. The "scale" property specifies 2 or 4 digits to the right of the decimal point. The remainder of the precision is to the left of the decimal point.

For MONEY(4), the largest number is ±9,999,999,999,999,999,999,999,999,999.9999. The smallest fraction is ±0.0001.

For MONEY(2), the largest number is ±999,999,999,999,999,999,999,999,999,999.99. The smallest fraction is ±0.01.

Unlike REAL and DOUBLE, MONEY is a fixed decimal number with no loss of precision and no base two rounding errors. NUMERIC works the same as MONEY but allows more digits to the right of the decimal point. FairCom's integer field types include TINYINT (1 byte), SMALLINT (2 bytes), INTEGER (4 bytes), and BIGINT (8 bytes).

MONEY's behavior in different APIs:
  • In FairCom's JSON DB API, a MONEY value is represented as a JSON number or string.

    The string representation is useful because some JSON parsers and programming languages cannot properly handle numbers with this range.

  • In FairCom's SQL API, a MONEY value is submitted and returned as a number USING ASCII characters — for example, -123.45 or -123.456 .

  • In FairCom's ISAM and CTDB APIs, a MONEY value is submitted and returned as a FairCom proprietary, 19-byte, binary structure. FairCom provides functions to convert a FairCom MONEY into number types used by programming languages.

DOUBLE is a FairCom database field type containing a signed floating point number, such as -179769313.48623158 or 2.2250738585072014e-308. It is stored in a record as an 8-byte, IEEE 754 , binary floating point number. It supports a wide range of numbers and its calculations are fast. It provides 15 to 19 digits of approximate precision. It supports infinity, -infinity, and NaN.

Its safe integer range is from −9,007,199,254,740,991 to 9,007,199,254,740,991. Its largest number is ±1.7976931348623158e+308. Its smallest fraction is ±2.2250738585072014e-308.

Unlike NUMERIC and MONEY, DOUBLE is an approximate number because precision is automatically truncated to accommodate larger numbers and smaller fractions. Because DOUBLE is a base two number, it has rounding errors when converting to and from base ten numbers.

In contrast, FairCom's precise fixed point numbers include NUMERIC and MONEY. FairCom's integer field types include TINYINT (1 byte), SMALLINT (2 bytes), INTEGER (4 bytes), and BIGINT (8 bytes). FairCom's base two floating point numbers include DOUBLE and REAL.

DOUBLE's behavior in different APIs:
  • In FairCom's JSON DB API, a DOUBLE value is represented in JSON as a number or a string.

    The string representation is useful because most JSON parsers and some programming languages cannot properly infinity, -infinity, and NaN values.

  • In FairCom's SQL API, a DOUBLE value is submitted and returned as a number using ASCII characters — for example, 123.0 or -123.456 .

  • In FairCom's ISAM and CTDB

  • CTDB APIs, a DOUBLE value is submitted and returned as an 8-byte IEEE 754 float.

REAL is a FairCom database field type containing a signed floating point number, such as -34028234.664 or 1.1754943508e-38. It is stored in a record as a 4-byte, IEEE 754, binary floating point number. It provides 6 to 9 decimal digits of approximate precision. In contrast, DOUBLE provides 15 to 19 digits of approximate precision. REAL also supports infinity, -infinity, and NaN.

Its safe integer range is from −9,999,999 to 9,999,999. Its largest number is ±3.4028234664e+38. Its smallest fraction is ±1.1754943508e-38.

Unlike NUMERIC and MONEY, REAL is an approximate number because precision is automatically truncated to accommodate larger numbers and smaller fractions. Because it is a base two number, it has rounding errors when converting to and from base ten numbers.

In contrast, FairCom's precise fixed point numbers include NUMERIC and MONEY. FairCom's integer field types include TINYINT (1 byte), SMALLINT (2 bytes), INTEGER (4 bytes), and BIGINT (8 bytes). FairCom's base-two floating point numbers include DOUBLE and REAL.

REAL's behavior in different APIs:
  • In FairCom's JSON DB API, a REAL value is represented in JSON as a number or a string.

    The string representation is useful because most JSON parsers and some programming languages cannot properly handle infinity, -infinity, and NaN values.

  • In FairCom's SQL API, a REAL value is submitted and returned as a number using ASCII characters — for example, 123.001 or -0.1234.

  • In FairCom's ISAM and CTDB APIs, a REAL value is submitted and returned as a 4-byte IEEE 754 float.