Site Menu Project Specification Implementation Recommendations Reference Needs Updating Work in Progress Wastebasket Wiki Manual |
BCDSpec.BCD HistoryHide minor edits - Show changes to output 2010-05-24 11:53
by -
Changed lines 1-5 from:
[@DEFINITION MODULE BCD; (* Binary Coded Decimals *) to:
[@DEFINITION MODULE BCD [RTYPE]; (* Single Precision Binary Coded Decimals *) Changed line 12 from:
BCD = OPAQUE to:
BCD = OPAQUE RECORD Changed lines 14-20 from:
END; CONST [TMIN] minValue = -9.9999999999999E+99; to:
END; (* BCD *) (* R-Type bindings to operators, pervasives and primitives: *) (* Range *) CONST [TMIN] minValue = -9.9999999999999E+99; (* Smallest value of type BCD. This value is bound to TMIN for type BCD. *) Changed lines 26-36 from:
PROCEDURE [:=] assign ( VAR assignTo : BCD; literal : ARRAY OF CHAR (* type conversions PROCEDURE [: to:
(* Largest value of type BCD. This value is bound to TMAX for type BCD. *) (* Literal assignment *) PROCEDURE [:=] assign ( VAR assignTo : BCD; literal : ARRAY OF CHAR ); (* Converts string literal to a BCD value and assigns it to assignTo. This procedure is bound to the := operator for literal assignment. *) (* Type conversions *) PROCEDURE [::] toCARD ( a : BCD ) : CARDINAL; (* Converts BCD value a to a CARDINAL value and returns it. This function is bound to the :: operator for BCD to CARDINAL conversion. *) Changed lines 43-45 from:
to:
(* Converts BCD value a to an INTEGER value and returns it. This function is bound to the :: operator for BCD to INTEGER conversion. *) Changed lines 47-79 from:
PROCEDURE [ABS] abs ( a : BCD ) : BCD; PROCEDURE [NEG] neg ( a (* dyadic arithmetic operations PROCEDURE [+] add ( a, b : BCD ) PROCEDURE [-] sub PROCEDURE [*] multiply ( a, b : BCD ) : BCD; PROCEDURE [/] divide ( a, b : BCD ) (* relational operations *) PROCEDURE [=] isEqual ( a, b : BCD ) : BOOLEAN; PROCEDURE [<] isLess ( a, b : BCD ) : BOOLEAN; PROCEDURE [>] isGreater ( a, b : BCD ) : BOOLEAN; (* scalar conversion primitives CONST digitCapacity = 15; (* total to:
(* Converts BCD value a to a REAL value and returns it. This function is bound to the :: operator for BCD to REAL conversion. *) (* Monadic arithmetic operations *) PROCEDURE [ABS] abs ( a : BCD ) : BCD; (* Returns the absolute value of BCD value a. This function is bound to pervasive function ABS for type BCD. *) PROCEDURE [NEG] neg ( a : BCD ) : BCD; (* Returns the sign reversed value of BCD value a. This function is bound to the unary minus operator for type BCD. *) (* Dyadic arithmetic operations *) PROCEDURE [+] add ( a, b : BCD ) : BCD; (* Adds BCD values a and b and returns the result. This function is bound to the + operator for type BCD. *) PROCEDURE [-] sub ( a, b : BCD ) : BCD; (* Subtracts BCD value b from a and returns the result. This function is bound to the - operator for type BCD. *) PROCEDURE [*] multiply ( a, b : BCD ) : BCD; (* Multiplies BCD values a and b and returns the result. This function it bound to the * operator for type BCD. *) PROCEDURE [/] divide ( a, b : BCD ) : BCD; (* Divives BCD value a by b and returns the result. This function is bound to the / operator for type BCD. *) (* Relational operations *) PROCEDURE [=] isEqual ( a, b : BCD ) : BOOLEAN; (* Returns TRUE if BCD values a and b are equal, otherwise FALSE. This function is bound to operators = and # for type BCD. *) PROCEDURE [<] isLess ( a, b : BCD ) : BOOLEAN; (* Returns TRUE if BCD value a is less than b, otherwise FASLE. This function is bound to operators < and >= for type BCD. *) PROCEDURE [>] isGreater ( a, b : BCD ) : BOOLEAN; (* Returns TRUE if BCD value a is greater than b, otherwise FALSE. This function is bound to operators > and <= for type BCD. *) (* Scalar conversion primitives *) CONST digitCapacity = 15; (* maximum digits *) Changed lines 101-108 from:
(* PROCEDURE [FROM] fromSXF ( VAR b : BCD; s : ARRAY OF CHAR ); (* convert a string in scalar exchange format to a BCD value *) (* IO operations, bound to READ, WRITE and WRITEF to:
(* Converts a BCD 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 : BCD; CONST s : ARRAY OF CHAR ); (* Converts a string in scalar exchange format to a BCD value. This procedure is used to synthesise conversions from other scalar types when no direct conversion path exists. *) (* IO operations *) Changed line 114 from:
(* Reads the textual representation of a BCD value to:
(* Reads the textual representation of a BCD value from input stream infile Changed lines 116-125 from:
- any remaining characters that are part of the numeral being read are PROCEDURE Write( outfile : File; b : BCD ); (* Writes the textual representation of value b in simple format to output stream outfile *) PROCEDURE WriteF( outfile : File; fmtStr : ARRAY OF CHAR (* Writes a formatted textual representation of one or more BCD values to output stream outfile. The value of parameter items is calculated and inserted automatically. The output format is determined by fmtStr. 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 BCD argument. *) PROCEDURE Write( outfile : File; CONST b : BCD ); (* Writes the textual representation of value b to output stream outfile. This procedure is substituted for invocations of WRITE with a BCD argument. *) PROCEDURE WriteF ( outfile : File; CONST fmtStr : ARRAY OF CHAR; items : VARIADIC OF CONST BCD ); (* Writes a formatted textual representation of one or more BCD values to output stream outfile. The output format is determined by fmtStr. This procedure is substituted for invocations of WRITEF with one or more BCD arguments. *) 2010-04-11 11:28
by -
Deleted lines 37-47:
CONST digitCapacity = 15; (* total digits *) PROCEDURE [TO] toSXF ( b : BCD; VAR s : ARRAY OF CHAR ); (* convert a BCD value to a string in scalar exchange format *) PROCEDURE [FROM] fromSXF ( VAR b : BCD; s : ARRAY OF CHAR ); (* convert a string in scalar exchange format to a BCD value *) Added lines 63-73:
(* scalar conversion primitives *) CONST digitCapacity = 15; (* total digits *) PROCEDURE [TO] toSXF ( b : BCD; VAR s : ARRAY OF CHAR ); (* convert a BCD value to a string in scalar exchange format *) PROCEDURE [FROM] fromSXF ( VAR b : BCD; s : ARRAY OF CHAR ); (* convert a string in scalar exchange format to a BCD value *) 2010-04-11 11:23
by -
Changed line 40 from:
CONST digitCapacity = 15; (* total digits to:
CONST digitCapacity = 15; (* total digits *) 2010-04-11 11:23
by -
Changed lines 15-18 from:
CONST digitCapacity = 15; (* experimental *) to:
Changed lines 38-42 from:
(* conversion primitives *) PROCEDURE [FROM] fromSerialized ( to:
(* scalar conversion primitives *) CONST digitCapacity = 15; (* total digits in native representation *) PROCEDURE [TO] toSXF ( b : BCD; VAR s : ARRAY OF CHAR ); (* convert a BCD value to a string in scalar exchange format *) PROCEDURE [FROM] fromSXF ( VAR b : BCD; s : ARRAY OF CHAR ); (* convert a string in scalar exchange format to a BCD value *) 2010-04-10 16:47
by -
Changed lines 16-18 from:
to:
CONST digitCapacity = 15; (* experimental *) Deleted lines 40-41:
CONST [LENGTH] maxDigits = 16; (* experimental *) 2010-04-10 16:04
by -
Changed lines 40-49 from:
CONST [LENGTH] PROCEDURE [TO] VAR significand : ARRAY OF CHAR; VAR exponent : ARRAY OF CHAR ); PROCEDURE [FROM] fromASCII ( isDecimal : BOOLEAN; significand : ARRAY OF CHAR; exponent : ARRAY OF CHAR ) : BCD to:
CONST [LENGTH] maxDigits = 16; (* experimental *) PROCEDURE [TO] toSerialized ( value : BCD; VAR serialized : ARRAY OF CHAR ); PROCEDURE [FROM] fromSerialized ( VAR value : BCD; serialized : ARRAY OF CHAR ); 2010-04-07 16:31
by -
Changed line 40 from:
CONST [LENGTH] requiredDigits = 16; to:
CONST [LENGTH] requiredDigits = 16; (* experimental *) 2010-04-07 14:26
by -
Changed line 42 from:
PROCEDURE [TO] toASCII ( value : BCD; to:
PROCEDURE [TO] toASCII ( value : BCD; Changed lines 45-47 from:
VAR exponent PROCEDURE [FROM] fromASCII ( isDecimal : BOOLEAN; to:
VAR exponent : ARRAY OF CHAR ); PROCEDURE [FROM] fromASCII ( isDecimal : BOOLEAN; Changed line 49 from:
exponent : ARRAY OF CHAR ) : BCD; to:
exponent : ARRAY OF CHAR ) : BCD; 2010-04-07 14:25
by -
Added lines 40-41:
CONST [LENGTH] requiredDigits = 16; Changed lines 43-49 from:
VAR isDecimal VAR exponent PROCEDURE [FROM] fromASCII ( isDecimal exponent : ARRAY OF CHAR ) : BCD; to:
VAR isDecimal : BOOLEAN; VAR significand : ARRAY OF CHAR; VAR exponent : ARRAY OF CHAR ); PROCEDURE [FROM] fromASCII ( isDecimal : BOOLEAN; significand : ARRAY OF CHAR; exponent : ARRAY OF CHAR ) : BCD; 2010-04-06 16:54
by -
Deleted lines 15-19:
(* number type *) CONST [TYPE] semanticModel = 'R'; (* obsolete *) 2010-04-06 07:36
by -
Changed lines 43-44 from:
(* to:
(* conversion primitives *) Changed lines 51-52 from:
exponent : ARRAY OF CHAR ) : BCD; to:
mantissa : ARRAY OF CHAR; exponent : ARRAY OF CHAR ) : BCD; 2010-04-06 07:35
by -
Changed line 45 from:
PROCEDURE [ to:
PROCEDURE [TO] toASCII ( value : BCD; Changed line 50 from:
PROCEDURE [ to:
PROCEDURE [FROM] fromASCII ( isDecimal : BOOLEAN; 2010-04-06 07:21
by -
Changed line 45 from:
PROCEDURE [ to:
PROCEDURE [""] toASCII ( value : BCD; Changed line 50 from:
PROCEDURE [ to:
PROCEDURE [""] fromASCII ( isDecimal : BOOLEAN; 2010-04-06 07:15
by -
Changed line 43 from:
(* fallback to:
(* fallback conversion primitives *) 2010-04-06 07:11
by -
Changed line 42 from:
PROCEDURE [::] toASCII ( value : BCD; to:
PROCEDURE [::] toASCII ( value : BCD; Changed lines 44-45 from:
VAR mantissa VAR exponent : ARRAY OF CHAR ); to:
VAR mantissa : ARRAY OF CHAR; VAR exponent : ARRAY OF CHAR ); 2010-04-06 07:10
by -
Changed line 42 from:
PROCEDURE [::] toASCII ( value : BCD; to:
PROCEDURE [::] toASCII ( value : BCD; 2010-04-06 07:09
by -
Changed lines 48-49 from:
mantissa exponent : ARRAY OF CHAR ) : BCD; to:
mantissa : ARRAY OF CHAR; exponent : ARRAY OF CHAR ) : BCD; 2010-04-06 07:08
by -
Changed lines 48-49 from:
exponent : ARRAY OF CHAR ) : BCD; to:
mantissa : ARRAY OF CHAR; exponent : ARRAY OF CHAR ) : BCD; 2010-04-06 07:08
by -
Added lines 41-49:
PROCEDURE [::] toASCII ( value : BCD; VAR isDecimal : BOOLEAN; VAR mantissa : ARRAY OF CHAR; VAR exponent : ARRAY OF CHAR ); PROCEDURE [::] fromASCII ( isDecimal : BOOLEAN; mantissa : ARRAY OF CHAR; exponent : ARRAY OF CHAR ) : BCD; 2010-04-05 12:36
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-04 11:48
by -
Deleted lines 30-31:
2010-04-04 09:18
by -
Changed lines 17-21 from:
(* number CONST [TYPE] semanticModel = 'R'; to:
(* number type *) CONST [TYPE] semanticModel = 'R'; Changed lines 45-46 from:
(* to:
(* monadic arithmetic operations *) Changed line 54 from:
(* to:
(* dyadic arithmetic operations *) 2010-04-04 09:14
by -
Changed line 19 from:
CONST [TYPE] to:
CONST [TYPE] semanticModel = 'R'; (* real number type *) 2010-04-04 09:14
by -
Changed line 19 from:
CONST [ to:
CONST [TYPE] typeSemantics = 'R'; (* real number type *) 2010-03-23 05:44
by -
Changed lines 74-76 from:
(* IO operations (* hooks for standard procedures to:
(* IO operations, bound to READ, WRITE and WRITEF *) 2010-03-23 05:42
by -
Changed lines 19-21 from:
CONST to:
CONST [R] isRealNumberType = TRUE; Deleted lines 74-105:
(* The EBNF for the textual representation of a value of type BCD is equivalent to that of type REAL: bcdValue : unpaddedBCDValue | leftPaddedBCDValue | rightPaddedBCDValue ; leftPaddedBCDValue : padding+ unPaddedBCDValue ; rightPaddedBCDValue : unPaddedBCDValue padding+ ; unPaddedBCDValue : 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. *) 2010-03-23 05:25
by -
Added lines 108-109:
(* hooks for standard procedures READ, WRITE and WRITEF *) Changed line 115 from:
- the file status is set to any of to:
- the file status is set to any of success, outOfRange, wrongFormat, endOfLine, or endOfInput *) 2010-03-19 20:54
by -
Deleted line 18:
Deleted line 19:
2010-03-19 20:31
by -
Changed lines 17-21 from:
(* CONST [ CONST to:
(* number system *) CONST [Z] isWholeNumberType = FALSE; CONST [R] isRealNumberType = TRUE; CONST [C] isComplexNumberType = FALSE; 2010-03-19 07:52
by -
Changed lines 5-9 from:
FROM FileIO IMPORT File; to:
FROM FileIO IMPORT File; (* required for IO *) (* BCD type *) 2010-03-19 07:50
by -
Changed lines 29-33 from:
CONST [.] decimalPointLiterals = TRUE; PROCEDURE [:=] assign ( VAR v to:
CONST [.] decimalPointLiterals = TRUE; (* decimal point literals are assignment compatible *) PROCEDURE [:=] assign ( VAR assignTo : BCD; literal : ARRAY OF CHAR ); Changed line 40 from:
PROCEDURE [::] toREAL ( a : BCD ) : REAL; to:
PROCEDURE [::] toREAL ( a : BCD ) : REAL; 2010-03-19 07:45
by -
Changed line 9 from:
value : to:
value : ARRAY 8 OF OCTET; (* 64 bits *) Changed lines 12-33 from:
(* CONST [TMIN] minValue = -9.9999999999999E+99; [TMAX] maxValue = +9.9999999999999E+99; ( CONST isOrdinal [..] = FALSE; decimalPoint [.] = TRUE; minValue [TMIN] = -9.9999999999999E+99; maxValue [TMAX] = +9.9999999999999E+99; CONST isOrdinal [ORD] = FALSE; (* implies decimal point *) minValue [TMIN] = -9.9999999999999E+99; maxValue [TMAX] = +9.9999999999999E+99; to:
(* ordinality *) CONST [..] isOrdinal = FALSE; (* alternative #1 *) CONST [ORD] isOrdinal = FALSE; (* alternative #2 *) Changed lines 22-25 from:
to:
CONST [TMIN] minValue = -9.9999999999999E+99; CONST [TMAX] maxValue = +9.9999999999999E+99; Changed lines 29-32 from:
PROCEDURE [:=] assign ( to:
CONST [.] decimalPointLiterals = TRUE; PROCEDURE [:=] assign ( VAR v : BCD; literal : ARRAY OF CHAR ); Changed lines 36-37 from:
PROCEDURE [::] toCARD (a : BCD ) : CARDINAL; to:
PROCEDURE [::] toCARD ( a : BCD ) : CARDINAL; Added line 42:
Added line 51:
Added line 62:
Deleted lines 66-73:
PROCEDURE [,] isOrdinalType : BOOLEAN; PROCEDURE [..] isOrdinalType : BOOLEAN; PROCEDURE [<>] isOrdinalType : BOOLEAN; Deleted lines 68-69:
Deleted line 70:
2010-03-18 16:37
by -
Changed line 29 from:
isOrdinal [ORD] = FALSE; (* implies to:
isOrdinal [ORD] = FALSE; (* implies decimal point *) 2010-03-18 16:37
by -
Added lines 25-29:
minValue [TMIN] = -9.9999999999999E+99; maxValue [TMAX] = +9.9999999999999E+99; CONST isOrdinal [ORD] = FALSE; (* implies no decimal point *) 2010-03-18 16:30
by -
Added lines 19-27:
(* or like this perhaps ... *) CONST isOrdinal [..] = FALSE; decimalPoint [.] = TRUE; minValue [TMIN] = -9.9999999999999E+99; maxValue [TMAX] = +9.9999999999999E+99; 2010-03-18 16:21
by -
Added lines 12-19:
(* it would help if the following values are constants *) CONST [..] isOrdinal = FALSE; [.] decimalPointLiterals = TRUE; [TMIN] minValue = -9.9999999999999E+99; [TMAX] maxValue = +9.9999999999999E+99; 2010-03-18 10:25
by -
Changed lines 14-16 from:
PROCEDURE [ PROCEDURE [ to:
PROCEDURE [TMIN] minValue : BCD; PROCEDURE [TMAX] maxValue : BCD; 2010-03-18 10:09
by -
Deleted lines 51-52:
Added lines 55-58:
PROCEDURE [..] isOrdinalType : BOOLEAN; PROCEDURE [<>] isOrdinalType : BOOLEAN; |