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. For example, when you declare a local name in a procedure with the type
integer, an action or procedure statement can assign into that local name only a value that meets the requirements for integer numbers.
integer represents an integral number. G2 integer values are signed with 30-bit precision. A G2 integer value can range from -229to (229 - 1).
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.
Float values in G2 are signed, with a 64-bit, floating-point representation. On most platforms that G2 supports, a float value can range from ±1.79 x 10308 to ±2.22 x 10-308 with approximately 16 digits of precision.
float value can range from ±8.9 x 10307 to ±5.5 x 10-309. float values in conformance with the IEEE's Standard for Binary Floating-Point Arithmetic (ANSI/IEEE Standard 754-1985). For G2 to conform to this standard, the computer on which G2 runs must also support that standard. For example, the VAX/VMS platform does not support floating-point arithmetic as defined in ANSI/IEEE Std. 754-1985.
float values can result in these exceptional float values:
The ANSI/IEEE Standard 754-1985 document specifies how exceptional floating point values participate in arithmetic operations. G2 conforms to this standard on platforms that support it.
false.
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. integer value to a float value, G2 automatically coerces the integer value to a float value, then compares the two values.
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:
KB Workspace > New Definition > units-of-measure-declaration.
![]() |
units of measure are:
{plural-unit-of-measure-symbol
[singular (single-unit-of-measure-symbol )]} [,...]
![]() |
initially is statement in a class definition, for attributes without a type
Data-type attribute of quantitative, integer, and float variables and parameters
Initial-value attribute of quantity, float, and integer variables and parameters
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.
Use
symbol values to represent identifiers: names of items, attributes, classes, and types. 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.
When creating a symbol value, the first character can consist of any Unicode character. All characters in a symbol value are uppercase unless you quote them.
Tip: To quote any character, precede it with the at sign (@) character in the Text Editor.
Symbols can include lowercase characters from supported Unicode languages by quoting the characters. You can quote any Unicode character.
! " # $ & ( ) * + , / : ; < = > ? @
[ ] ^ ' { | } ~ ©® · ¢ £ ¥ » « ¡ ¿
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.
| Valid symbols: | Invalid symbols: |
|---|---|
|
@!7
|
.777
|
|
'123
|
123
|
|
-._
|
!!$
|
|
12@3
|
|
|
my-object
|
|
|
@my-object
|
|
G2 always ignores the case of all unquoted alphabetic characters. For example, in the next procedure, G2 always executes the
inform action, as shown in the message displayed:
![]() |
When entering special characters in the Text Editor, first quote the character using the at sign (@), and then press Alt + i, followed by the special character you require. In this procedure example, the trademark symbol is available by entering Alt + i t.
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.
Use
text values to contain any sequence of characters, including case-sensitive alphabetic characters. The maximum number of characters in a text value is 65535. 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. text value, though quoting is unnecessary for all characters in the Unicode character set, except:
text value.
text value is described in Evaluating Expressions. For a description of the concatenation operation on text values, see Using the Concatenation Operator.
The following procedure
DEMONSTRATE-EQUAL-TEXTS demonstrates these facts about text values:
text value.
![]() |
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:
Press Control + j anywhere within the quoted text value that you want a newline to appear.
![]() |
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:
Press Return anywhere within the quoted text value that you want a newline to appear.
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. A value of type
truth-value ranges from -1.0 true (completely false) to +1.0 true (completely true).
-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. -1.0 true and less than +1.0 true. For example, the following
conclude action assigns a value into a truth-value attribute of an item of a user-defined class, based on the result of evaluating the expression (the volume-in-liters of tank-1 > 100) ( +- 25 ) :
conclude that the truth-value-attribute of my-object =
(the volume-in-liters of tank-1 >100)(+- 25 )
( +- 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.