# Working With Specific Types

The G2 specific types are `integer`, `float`, `symbol`, `text`, and `truth-value`. Each value that your KB directly manipulates has a specific type. Your KB cannot create user-defined specific types.

## Using the Integer Type

A value of type `integer` represents an integral number. G2 `integer` values are signed with 30-bit precision. A G2 `integer` value can range from -229to (229 - 1).

Note: For actions that update the value of an integer value, G2 does not check for integer overflow or underflow because of the performance penalty such checking would impose.

## Using the Float Type

A value of type `float` represents a real number with a floating-point representation. Due to the limitations of the floating-point representation for real numbers, it is possible for a particular `float` value to represent an approximation of a real number. This only occurs for very large and very small numbers.

Note: On a VAX/VMS platform, a `float` value can range from ±8.9 x 10307 to ±5.5 x 10-309.

## Working With Exceptional Float Values

Arithmetic operations on `float` values can result in these exceptional float values:

Note: If G2 produces a `NaN` (not a number) value, the VAX/VMS, OpenVMS, and Alpha OSF platforms signal an error.

## Coercing Numeric Values

Some G2 arithmetic and relational operators require G2 to coerce an `integer` value to a `float` value. This means that G2 automatically creates a temporary copy of a value in a different type, for use in evaluating an expression.

Tip: For the details about how G2 coerces numeric values when applying arithmetic and relational operators, see Coercion of Values Returned from Arithmetic Operators.

## Using Units of Measure for Numeric Values

You can create your own set of symbols to represent units of measure, such as meters, pounds, and liters, that G2 does not provide. You define these symbols in a `UNITS-OF-MEASURE-DECLARATION` item.

To create a unit of measure:

For example, this units of measure declaration declares meters and centimeters:

## Using the Symbol Type

A `symbol` value contains a series of characters, each of which is a member of the Unicode character set. For more information about the Unicode character set, see Chapter 40, G2 Character Support.

### Working With Characters in a Symbol Value

The Unicode character set supports alphabetic and ideographic characters from most of the world's modern and classical languages. For a discussion of Unicode, see Chapter 40, G2 Character Support.

Tip: To quote any character, precede it with the at sign (@) character in the Text Editor.

These characters also require quoting:

Note: For information about entering Unicode characters, see Entering Unicode Character Codes.

If you begin a symbol value with a period (.) or a number (0 - 9), it must also include at least one alphabetic character or quote one of its numeric characters or any of the Unicode character set symbol, punctuation, or special characters. The hyphen (-), underscore (_), period (.) , and apostrophe (') characters are exceptions, which do not require quoting.

## Using the Text Type

A `text` value contains a series of characters, each of which must be a member of the Unicode character set. For more information about the Unicode character set, see Chapter 40, G2 Character Support.

### Working With Characters in a Text Value

G2 allows any character from the Unicode character set in a `text` value. The case of characters is significant. G2 retains, displays, and prints the case of all alphabetic characters.

Specifying a literal `text` value is described in Evaluating Expressions. For a description of the concatenation operation on `text` values, see Using the Concatenation Operator.

### Formatting Text Values

You can include a newline character in a literal `text` value to format lengthy text. The way to include a newline character depends on whether you are editing the text in a non-scrolling editor, such as for messages and other free text items, or a scrolling editor, such as for procedures and methods.

To enter a newline character in a text value in a non-scrolling editor:

This example illustrates the use of Control + j newline sequences in a free-text item:

Note: Any newline characters that you enter to format text values are stored as Unicode line separator characters. Such newline characters do not, therefore, translate into ASCII newline character values when exporting text from G2.

To enter a newline character in a text value within a scrolling editor:

## Using the Truth-Value Type

A value of type `truth-value` represents a degree of certainty in the truth of a condition, comparison, or assertion. Your KB can use values of type `truth-value` to implement a reasoning strategy based on the principles of either boolean logic or fuzzy logic.

Tip: G2 displays a truth-value of `-1.0 true` simply as `false`, and displays a truth-value of `+1.0 true` simply as `true`. In this case the displayed values `true` and `false` represent truth-values, not symbols.

In this example, the subexpression `( +- 25 )` signifies a fuzzy truth band. The degree to which the `Volume-in-liters` of `tank-1` is greater than, equal to, or less than the value 100, determines the fuzzy truth value that G2 assigns to the `Truth-value-attribute` of `my-object`.

Tip: For the details about specifying fuzzy truth band expressions, see Producing Fuzzy Truth Values From Relational Operations.