Site Menu Project Specification Implementation Recommendations Reference Needs Updating Work in Progress Wastebasket Wiki Manual |
LONGBCDSpec.LONGBCD HistoryHide minor edits - Show changes to output 2010-05-24 11:55
by -
Changed lines 1-2 from:
[@DEFINITION MODULE LONGBCD; to:
[@DEFINITION MODULE LONGBCD [RTYPE]; Changed line 12 from:
to:
LONGBCD = OPAQUE RECORD Changed lines 14-22 from:
END; CONST digitCapacity = 30; ( (* CONST [TMIN] minValue = -9.99999999999999999999999999E+999; to:
END; (* LONGBCD *) (* R-Type bindings to operators, pervasives and primitives: *) (* Range *) CONST [TMIN] minValue = -9.99999999999999999999999999E+999; (* Smallest value of type LONGBCD. This value is bound to TMIN for type LONGBCD. *) Changed lines 27-73 from:
(* assignment *) PROCEDURE [:=] assign ( VAR assignTo : LONGBCD; literal : ARRAY OF CHAR ); (* type conversions *) PROCEDURE [::] toLONGCARD ( a : LONGBCD ) : LONGCARD; PROCEDURE [::] toLONGINT ( a : LONGBCD ) : LONGINT; PROCEDURE [::] toLONGREAL ( a : LONGBCD ) : LONGREAL; (* monadic arithmetic operations *) PROCEDURE [ABS] abs ( a : LONGBCD ) : LONGBCD; PROCEDURE [NEG] neg ( a : LONGBCD ) : LONGBCD; (* dyadic arithmetic operations *) PROCEDURE [+] add ( a, b : LONGBCD ) : LONGBCD; PROCEDURE [-] sub ( a, b : LONGBCD ) : LONGBCD; PROCEDURE [*] multiply ( a, b : LONGBCD ) : LONGBCD; PROCEDURE [/] divide ( a, b : LONGBCD ) : LONGBCD; (* relational operations *) PROCEDURE [=] isEqual ( a, b : LONGBCD ) : BOOLEAN; PROCEDURE [<] isLess ( a, b : LONGBCD ) : BOOLEAN; PROCEDURE [>] isGreater ( a, b : LONGBCD ) : BOOLEAN; (* scalar conversion primitives *) CONST digitCapacity = 31; (* total digits *) to:
(* Largest value of type LONGBCD. This value is bound to TMAX for type LONGBCD. *) (* Literal assignment *) PROCEDURE [:=] assign ( VAR assignTo : LONGBCD; literal : ARRAY OF CHAR ); (* Converts string literal to a LONGBCD value and assigns it to assignTo. This procedure is bound to the := operator for literal assignment. *) (* Type conversions *) PROCEDURE [::] toCARD ( a : LONGBCD ) : CARDINAL; (* Converts LONGBCD value a to a CARDINAL value and returns it. This function is bound to the :: operator for LONGBCD to CARDINAL conversion. *) PROCEDURE [::] toINT ( a : LONGBCD ) : INTEGER; (* Converts LONGBCD value a to an INTEGER value and returns it. This function is bound to the :: operator for LONGBCD to INTEGER conversion. *) PROCEDURE [::] toREAL ( a : LONGBCD ) : REAL; (* Converts LONGBCD value a to a REAL value and returns it. This function is bound to the :: operator for LONGBCD to REAL conversion. *) (* Monadic arithmetic operations *) PROCEDURE [ABS] abs ( a : LONGBCD ) : LONGBCD; (* Returns the absolute value of LONGBCD value a. This function is bound to pervasive function ABS for type LONGBCD. *) PROCEDURE [NEG] neg ( a : LONGBCD ) : LONGBCD; (* Returns the sign reversed value of LONGBCD value a. This function is bound to the unary minus operator for type LONGBCD. *) (* Dyadic arithmetic operations *) PROCEDURE [+] add ( a, b : LONGBCD ) : LONGBCD; (* Adds LONGBCD values a and b and returns the result. This function is bound to the + operator for type LONGBCD. *) PROCEDURE [-] sub ( a, b : LONGBCD ) : LONGBCD; (* Subtracts LONGBCD value b from a and returns the result. This function is bound to the - operator for type LONGBCD. *) PROCEDURE [*] multiply ( a, b : LONGBCD ) : LONGBCD; (* Multiplies LONGBCD values a and b and returns the result. This function it bound to the * operator for type LONGBCD. *) PROCEDURE [/] divide ( a, b : LONGBCD ) : LONGBCD; (* Divives LONGBCD value a by b and returns the result. This function is bound to the / operator for type LONGBCD. *) (* Relational operations *) PROCEDURE [=] isEqual ( a, b : LONGBCD ) : BOOLEAN; (* Returns TRUE if LONGBCD values a and b are equal, otherwise FALSE. This function is bound to operators = and # for type LONGBCD. *) PROCEDURE [<] isLess ( a, b : LONGBCD ) : BOOLEAN; (* Returns TRUE if LONGBCD value a is less than b, otherwise FASLE. This function is bound to operators < and >= for type LONGBCD. *) PROCEDURE [>] isGreater ( a, b : LONGBCD ) : BOOLEAN; (* Returns TRUE if LONGBCD value a is greater than b, otherwise FALSE. This function is bound to operators > and <= for type LONGBCD. *) (* Scalar conversion primitives *) CONST digitCapacity = 30; (* maximum digits *) Changed lines 103-110 from:
(* PROCEDURE [FROM] fromSXF ( VAR b : LONGBCD; s : ARRAY OF CHAR ); (* convert a string in scalar exchange format to a LONGBCD value *) (* IO operations, bound to READ, WRITE and WRITEF to:
(* Converts a LONGBCD value to a string in scalar exchange format. This procedure is used to synthesise conversions to other scalar types when no direct conversion path exists. *) PROCEDURE [FROM] fromSXF ( VAR b : LONGBCD; CONST s : ARRAY OF CHAR ); (* Converts a string in scalar exchange format to a LONGBCD value. This procedure is used to synthesise conversions from other scalar types when no direct conversion path exists. *) (* IO operations *) Changed line 116 from:
(* Reads the textual representation of a LONGBCD value to:
(* Reads the textual representation of a LONGBCD value from input stream infile Changed lines 118-128 from:
- any remaining characters that are part of the numeral being read are PROCEDURE Write( outfile : File; b : LONGBCD ); (* Writes the textual representation of value b in simple format to output stream outfile *) PROCEDURE WriteF( outfile : File; fmtStr (* Writes a formatted textual representation of one or more LONGBCD values to output stream outfile. The to:
- any remaining characters that are part of the numeral being read are removed from infile - the numeric value of the numeral string read is assigned to the variable passed in for b - the file status is set to any of: success, outOfRange, wrongFormat, endOfLine, or endOfInput. This procedure is substituted for invocations of READ with a LONGBCD argument. *) PROCEDURE Write( outfile : File; CONST b : LONGBCD ); (* Writes the textual representation of value b to output stream outfile. This procedure is substituted for invocations of WRITE with a LONGBCD argument.*) PROCEDURE WriteF ( outfile : File; CONST fmtStr : ARRAY OF CHAR; items : VARIADIC OF CONST LONGBCD ); (* Writes a formatted textual representation of one or more LONGBCD values to output stream outfile. The output format is determined by fmtStr. This procedure is substituted for invocations of WRITEF with one or more LONGBCD arguments. *) 2010-04-11 11:26
by -
Deleted lines 39-45:
PROCEDURE [TO] toSerialized ( value : LONGBCD; VAR serialized : ARRAY OF CHAR ); PROCEDURE [FROM] fromSerialized ( VAR value : LONGBCD; serialized : ARRAY OF CHAR ); Added lines 65-75:
(* scalar conversion primitives *) CONST digitCapacity = 31; (* total digits *) PROCEDURE [TO] toSXF ( b : LONGBCD; VAR s : ARRAY OF CHAR ); (* convert a LONGBCD value to a string in scalar exchange format *) PROCEDURE [FROM] fromSXF ( VAR b : LONGBCD; s : ARRAY OF CHAR ); (* convert a string in scalar exchange format to a LONGBCD value *) 2010-04-10 16:44
by -
Changed lines 15-16 from:
to:
CONST digitCapacity = 30; (* experimental *) Deleted lines 40-41:
CONST [LENGTH] maxDigits = 30; (* experimental *) 2010-04-10 16:06
by -
Changed lines 40-47 from:
VAR mantissa : ARRAY OF CHAR; VAR exponent : ARRAY OF CHAR ); PROCEDURE [FROM] fromASCII ( isDecimal : BOOLEAN; mantissa : ARRAY OF CHAR; exponent : ARRAY OF CHAR ) : LONGBCD to:
CONST [LENGTH] maxDigits = 30; (* experimental *) PROCEDURE [TO] toSerialized ( value : LONGBCD; VAR serialized : ARRAY OF CHAR ); PROCEDURE [FROM] fromSerialized ( VAR value : LONGBCD; serialized : ARRAY OF CHAR ); 2010-04-06 16:53
by -
Deleted lines 15-19:
(* number type *) CONST [TYPE] semanticModel = 'R'; (* obsolete *) 2010-04-06 07:39
by -
Added lines 41-52:
(* conversion primitives *) PROCEDURE [TO] toASCII ( value : LONGBCD; VAR isDecimal : BOOLEAN; VAR mantissa : ARRAY OF CHAR; VAR exponent : ARRAY OF CHAR ); PROCEDURE [FROM] fromASCII ( isDecimal : BOOLEAN; mantissa : ARRAY OF CHAR; exponent : ARRAY OF CHAR ) : LONGBCD; 2010-04-05 12:15
by -
Changed line 12 from:
BCD = OPAQUE RECORD (" to:
BCD = OPAQUE RECORD ("R-Type") Changed line 19 from:
CONST [TYPE] semanticModel = 'R'; to:
CONST [TYPE] semanticModel = 'R'; (* obsolete *) 2010-04-05 12:14
by -
Changed line 12 from:
BCD = OPAQUE RECORD to:
BCD = OPAQUE RECORD ("C-Type") 2010-04-04 11:48
by -
Deleted lines 30-31:
2010-04-04 09:26
by - 2010-04-04 09:25
by -
Changed lines 5-6 from:
FROM FileIO IMPORT File; to:
FROM FileIO IMPORT File; (* required for IO *) (* LONGBCD type *) Changed lines 12-13 from:
value : to:
BCD = OPAQUE RECORD value : ARRAY 16 OF OCTET; (* 128 bits *) Added lines 16-21:
(* number type *) CONST [TYPE] semanticModel = 'R'; Changed lines 24-27 from:
to:
CONST [TMIN] minValue = -9.99999999999999999999999999E+999; CONST [TMAX] maxValue = +9.99999999999999999999999999E+999; Changed lines 31-34 from:
PROCEDURE [:=] assign ( literal : ARRAY OF CHAR ) : LONGBCD; to:
CONST [.] decimalPointLiterals = TRUE; (* decimal point literals are assignment compatible *) PROCEDURE [:=] assign ( VAR assignTo : LONGBCD; literal : ARRAY OF CHAR ); Changed lines 38-45 from:
PROCEDURE [::] toLONGCARD (a : PROCEDURE [::] toLONGINT ( a : PROCEDURE [::] toLONGREAL ( a : (* unary to:
PROCEDURE [::] toLONGCARD ( a : LONGBCD ) : LONGCARD; PROCEDURE [::] toLONGINT ( a : LONGBCD ) : LONGINT; PROCEDURE [::] toLONGREAL ( a : LONGBCD ) : LONGREAL; (* monadic arithmetic operations *) Changed lines 53-54 from:
(* to:
(* dyadic arithmetic operations *) Added line 64:
Changed lines 67-70 from:
PROCEDURE [=] isEqual PROCEDURE [#] isNotEqual to:
PROCEDURE [=] isEqual ( a, b : LONGBCD ) : BOOLEAN; Deleted lines 70-71:
Changed lines 73-108 from:
(* IO operations *) (* The EBNF for the textual representation of a value of type LONGBCD is equivalent to that of type BCD: longBCDValue : unpaddedLongBCDValue | leftPaddedLongBCDValue | rightPaddedLongBCDValue ; leftPaddedLongBCDValue : padding+ unPaddedLongBCDValue ; rightPaddedLongBCDValue : unPaddedLongBCDValue padding+ ; unPaddedLongBCDValue : simpleFormat | otherFormats ; otherFormats : sign? fillChar* ( fixedFmtNumeral | engFmtNumeral | expFmtNumeral ) suffix? ; simpleFormat : negativeSign? decimalDigit '.' decimalDigit+ exponent ; fixedFmtNumeral : integralPart decimalPoint fractionalPart ; engFmtNumeral : engIntegralPart decimalPoint fractionalPart engExponent ; expFmtNumeral : fixedFmtNumeral exponent ; padding : ' ' ; sign : ' ' | '+' | '-' ; negativeSign : '-' ; fillChar : ' ' | '*' | '0' ; integralPart : decimalDigit decimalDigit? decimalDigit? ( separator? digitGroup )* ; engIntegralPart : ( ( ( decimalDigit separator? )? decimalDigit )? decimalDigit )? decimalDigit ; fractionalPart : ( decimalDigit ( decimalDigit ( decimalDigit separator )? )? )* decimalDigit ; exponent : 'E' ( '+' | '-' ) decimalDigit decimalDigit+ ; engExponent : exponent ; decimalPoint : '.' | ',' ; separator : ' ' | '.' | ',' ; digitGroup : decimalDigit decimalDigit decimalDigit ; decimalDigit : '0' .. '9' ; suffix : ''' character* ''' ; Static semantics are as follows: decimalPoint and separator must never both use the same symbol the numeric value represented by engExponent must always be divisible by three. *) to:
(* IO operations, bound to READ, WRITE and WRITEF *) Changed lines 81-82 from:
- the file status is set to any of to:
- the file status is set to any of success, outOfRange, wrongFormat, endOfLine, or endOfInput *) Changed lines 86-88 from:
PROCEDURE WriteF( outfile : File; fmtStr : ARRAY OF CHAR; (* Writes a formatted textual representation of one or more LONGBCD values to output stream outfile. The value to:
PROCEDURE WriteF( outfile : File; fmtStr : ARRAY OF CHAR; items : CARDINAL; VARIADIC v[items] OF b : LONGBCD ); (* Writes a formatted textual representation of one or more LONGBCD values to output stream outfile. The value of parameter items is calculated and inserted automatically. The output format is determined by fmtStr. *) |