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.
integerrepresents an integral number. G2
integervalues are signed with 30-bit precision. A G2
integervalue can range from -229to (229 - 1).
floatrepresents 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
floatvalue to represent an approximation of a real number. This only occurs for very large and very small numbers.
Floatvalues in G2 are signed, with a 64-bit, floating-point representation. On most platforms that G2 supports, a
floatvalue can range from ±1.79 x 10308 to ±2.22 x 10-308 with approximately 16 digits of precision.
floatvalue can range from ±8.9 x 10307 to ±5.5 x 10-309.
floatvalues 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.
floatvalues can result in these exceptional float values:
|Exceptional Float Value||Display of Value in G2||Causes|
Negative overflow; divide a negative value of any numeric type by zero (0 or 0.0)
Positive overflow; divide a positive value of any numeric type by zero (0 or 0.0)
Not a number
Divide zero (0 or 0.0) by zero
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.
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 are:
[singular (single-unit-of-measure-symbol )]} [,...]
After you declare one or more units of measure, they appear after a numeric expression in the Text Editor prompts for:
initially isstatement in a class definition, for attributes without a type
Data-typeattribute of quantitative, integer, and float variables and parameters
Initial-valueattribute of quantity, float, and integer variables and parameters
symbolvalue 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.
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.
|Enter this character:||By:|
Pressing the Tab key one or more times. Each time you press the Tab key in the editor, G2 inserts the number of spaces designated in the |
Pressing the space bar.
Entering the Unicode character x2028.
Entering the Unicode character x2029.
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:|
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
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.
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:
textvalue is described in Evaluating Expressions. For a description of the concatenation operation on
textvalues, see Using the Concatenation Operator.
The following procedure
DEMONSTRATE-EQUAL-TEXTS demonstrates these facts about
textvalue 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.
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.
truth-valuerepresents a degree of certainty in the truth of a condition, comparison, or assertion. Your KB can use values of type
truth-valueto implement a reasoning strategy based on the principles of either boolean logic or fuzzy logic.
A value of type
-1.0 true(completely false) to
+1.0 true(completely true).
-1.0 truesimply as
false, and displays a truth-value of
+1.0 truesimply as
true. In this case the displayed values
falserepresent truth-values, not symbols.
-1.0 trueand less than
For example, the following
concludeaction assigns a value into a
truth-valueattribute 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
tank-1is greater than, equal to, or less than the value 100, determines the fuzzy truth value that G2 assigns to the