1、BRITISH STANDARD BS 6727:1987 ISO 6093:1985 Specification for Representation of numerical values in character strings for information interchange ISO title: Information processing Representation of numerical values in character strings for information interchange UDC 681.327.041:003.35BS 6727:1987 T
2、his British Standard, having been prepared under the directionof the Information Systems Technology Standards Committee, was published underthe authority of the Board ofBSI and comes into effect on 30April1987 BSI 12-1999 The following BSI references relate to the work on this standard: Committee re
3、ference IST/11 Draft for comment 84/61094 DC ISBN 0 580 15303 7 Committees responsible for this British Standard The preparation of this British Standard was entrusted by the Information Systems Technology Standards Committee (IST/-) to Technical Committee IST/11 upon which the following bodies were
4、 represented: Association for Payment Clearing Services British Computer Society Ltd. British Telecommunications plc Business Equipment and Information Technology Association Local Authorities Organization Amendments issued since publication Amd. No. Date of issue CommentsBS6727:1987 BSI 12-1999 i C
5、ontents Page Committees responsible Inside front cover National foreword ii 1 Scope and field of application 1 2 Conformance 1 3 References 1 4 Definitions 1 5 Character set 1 6 First numerical representation (NR1) 2 7 Second numerical representation (NR2) 2 8 Third numerical representation (NR3) 3
6、Annex A Method of syntax specification 6 Annex B Use of the character COMMA as decimal mark 6 Annex C Application to programming languages 6 Table 1 Examples of NR1 2 Table 2 Examples of NR2 3 Table 3 Examples of NR3 4 Table 4 Code table 5 Table 5 Examples of the application of this International St
7、andard to COBOL PICTURE character strings 7 Table 6 Examples of the application of this International Standard to the edit descriptors and sign control in the programming languageFORTRAN 8 Table 7 Examples of the application of this International Standard to FORMAT character strings in the programmi
8、ng language PL/I 9 Table 8 Examples of the application of this International Standard to PICTURE character strings in the programming language PL/I 10 Table 9 Examples of the application of this International Standard to field-width parameters in the programming language PASCAL 11 Publications refer
9、red to Inside back coverBS 6727:1987 ii BSI 12-1999 National foreword This British Standard has been prepared under the direction of the Information Systems Technology Standards Committee and is identical with ISO 6093:1985 “Information processing Representation of numerical values in character stri
10、ngs for information interchange”, published by the International Organization for Standardization (ISO). Terminology and conventions. The text of the International Standard has been approved as suitable for publication as a British Standard without deviation. Some terminology and certain conventions
11、 are not identical with thoseused in British Standards; attention is drawn especially to the following. The comma has been used as a decimal marker. In British Standards it is current practice to use a full point on the baseline as the decimal marker. Wherever the words “International Standard” appe
12、ar, referring to this standard, they should be read as “British Standard”. ISO 2022 is listed in clause 3 for information only. ISO2022:1986 is being implemented in the UK as an identical British Standard. NOTEIn C.3.5, line 1, “there has not be” should be read as “there has to be”. In 4.3, line 2,
13、“an” should be read as “a”. In Annex B, paragraph 3, line 4, “programing” should be read as “programming”. A British Standard does not purport to include all the necessary provisions of a contract. Users of British Standards are responsible for their correct application. Compliance with a British St
14、andard does not of itself confer immunity from legal obligations. Cross-references International Standard Corresponding British Standard ISO 4873:1986 BS 6006:1987 Specification for structure and rules forimplementation for United Kingdom 8-bit coded character set (Identical) a ISO 646:1983 BS 4730:
15、1985 Specification for UK 7-bit coded characterset (Identical exercising national options) a In preparation as a revision of BS 6006:1980. Summary of pages This document comprises a front cover, an inside front cover, pagesi andii, pages1 to12, an inside back cover and a back cover. This standard ha
16、s been updated (see copyright date) and may have had amendments incorporated. This will be indicated in the amendment table on the inside front cover.BS6727:1987 BSI 12-1999 1 1 Scope and field of application This International Standard specifies three presentations of numerical values, which are re
17、presented in character strings in a form readableby machine, for use in interchange between data processing systems. This International Standard also provides guidance fordevelopers of programming language standards andimplementors of programming products. Theserepresentations are recognizable by hu
18、mans, and thus may be useful in communication between humans. The base of representation is 10. This International Standard applies only to numerical values consisting of a finite number of digits with or without the decimal mark. It does not specify the mechanism to communicate the accuracy of the
19、number being represented or the method of delimiting the numerical representations or the organization of the numerical representations into larger aggregates. 2 Conformance A representation of a numerical value is in conformance with this International Standard if it is one of the three representat
20、ions specified herein. A conformance statement shall identify the representation and, where applicable, specify whether COMMA or FULL STOP is used as the decimal mark. In the absence of such a statement, the FULL STOP is deemed to be the decimal mark. 3 References ISO 646, Information processing ISO
21、 7-bit coded character set for information interchange. ISO 2022, Information processing ISO 7-bit and8-bit coded character sets Code extension techniques. ISO 4873, Information processing 8-bit code for information interchange Structure and rules for implementation. 4 Definitions For the purpose of
22、 this International Standard the following definitions apply. 4.1 decimal mark the character that separates the digits forming the integral part of a number from those forming the fractional part 4.2 field a continuous string of character positions on a data carrier 4.3 field description the set of
23、characteristics possessed by the field to ensure that its contents have an unique numerical interpretation to the interchange parties. For each field within a set of interchanged data the field description is specified in documentation associated with the interchange agreement between the parties. T
24、he field description includes the specification of the length of the field 4.4 length of a field the number of character positions of a field 4.5 positional notation a numeration system in which a real number is represented by a string of characters in such a way that the value contributed by a char
25、acter depends on its position as well as on its value 5 Character set 5.1 Description The character set for the representation of numerical values shall be a sub-set of the ISO646 coded character set. 5.2 Syntax The following syntatic objects are defined using themethod of syntax specification descr
26、ibed inAnnex A. 5.3 Semantics The digits shall be the characters coded in positions3/0 to 3/9 of ISO646. The remaining characters shall correspond to positions 2/0 (SPACE), 2/11 (PLUS SIGN), 2/12 (COMMA), 2/13 (MINUS SIGN), 2/14 (FULL STOP), 4/5 (CAPITAL LETTER E) and 6/5 (SMALLLETTER e). a) digit =
27、0/1/2/3/4/5/6/7/8/9 b) sign =+/ c) decimal-mark =,/. d) space =SPACE e) exponent-mark=E/eBS 6727:1987 2 BSI 12-1999 5.4 Coding The coding of the characters is specified in ISO646. Table 4 is reproduced from the code table for the IRV of the 7-bit coded character set in ISO646. Additional markings in
28、Table 4 identify the sub-set of characters specified above. 6 First numerical representation (NR1) The first numerical representation shall be a positional notation in which each number shall be represented by a string of digits, the decimal mark is implicit and its position fixed. NOTEThis represen
29、tation is also called: implicit-point representation. 6.1 Description Each instance of an NR1 shall be composed of optional leading SPACEs followed by a sign (inthesigned representation) and a string of digits. There shall be at least one digit. No embedded or trailing SPACEs shall be contained in t
30、he field. 6.2 Syntax 6.3 Semantics Each representation shall be contained in a field thelength of which shall be equal to the sum of the number of SPACEs and the number of digits, plus1 if a sign is present. At least one digit shall be present. In an unsigned NR1 the value represented shall be great
31、er than, or equal to, zero. In a signed NR1 the PLUS SIGN can be replaced by a SPACE. The implied decimal mark shall follow the right-most digit in the NR1, unless a scaling factor to be applied to the field is specified in accompanying documentation. The signed representation of the numerical value
32、 zero shall contain a PLUS SIGN or a SPACE, but not a MINUS SIGN. 6.4 Examples In the following examples the field length is assumed to be seven. The character SPACE is represented by %. Table 1 Examples of NR1 7 Second numerical representation (NR2) The second numerical representation shall be a po
33、sitional notation in which each number shall be represented by a string of characters, the decimal mark is explicity indicated by a specific character. NOTEThis representation is also called: explicit-point unscaled representation. 7.1 Description Each instance of an NR2 shall be composed of optiona
34、l leading SPACEs followed by a sign (inthesigned representation) and a string of digits. There shall be at least one digit. No embedded or trailing SPACEs shall be contained in the field. It is recommended that there is at least one digit to the left of the decimal mark even when there is at least o
35、ne to the right. 7.2 Syntax 7.3 Semantics Each representation shall be contained in a field thelength of which shall be equal to the sum of thenumber of SPACEs and of the number of digits, plus1; or plus 2 in the signed NR2, if the sign is present. At least one digit and the decimal mark shall be pr
36、esent. NR1 = unsigned-NR1/signed-NR1 unsigned-NR1 = space* digitdigit* signed-NR1 = space* (sign/space) digitdigit* Common notation Unsigned NR1 Signed NR1 4902 0004902 %04902 %4902 +004902 %+04902 %+4902 %4902 +1234 0001234 %1234 +001234 %+1234 %1234 56780 no representation 56780 %56780 0 0000000 %
37、0 +000000 %+0 %0 1234567 1234567 no representation NR2 = unsigned-NR2/signed-NR2 unsigned-NR2 = (space* digitdigit* decimal-mark digit*)/(space* digit* decimal-mark digitdigit*) signed-NR2 = (space* (sign/space) digitdigit* decimal-mark digit*)/(space* (sign/space) digit* decimal-mark digitdigit*)BS
38、6727:1987 BSI 12-1999 3 In an unsigned NR2 the value represented shall be greater than, or equal to, zero. In a signed representation the PLUS SIGN can be replaced by a SPACE. The position of the decimal mark shall represent the position of the actual decimal mark in the value, unless a scaling fact
39、or to be applied to the field is specified in accompanying documentation. The signed representation of the numerical value zero shall contain a PLUS SIGN or a SPACE, but not a MINUS SIGN. 7.4 Examples In the following examples the field length is assumed to be eight. Table 2 Examples of NR2 8 Third
40、numerical representation (NR3) The third numerical representation shall be a notation in which a number is represented by two strings of digits called significand and exponent. The value of the number equals the value of the significand multiplied by 10 raised to the power represented by the exponen
41、t. NOTEThis representation is also called: explicit-point scaled representation. 8.1 Description NR3 shall consist of representations of numerical values of the general form (A) E (B) which represent the value A 10 B where B is an integer. In each instance of an NR3 the significand shall be composed
42、 of optional leading SPACEs, followed by an optional sign (in the signed representation) and a string of digits. There shall be at least one digit in the significand; the location of the decimal mark in the significand is explicitly specified in the character string. The character E (or e) shall fol
43、low the significand, and the exponent, preceded by its sign, shall immediately follow the character E (or e). The exponent shall be composed of a leading sign followed by at least one digit. No embedded or trailing SPACEs shall be contained in the field. It is recommended that there is at least one
44、digit to the left of the decimal mark, even when there is at least one to the right. 8.2 Syntax 8.3 Semantics Each representation shall be contained in a field thelength of which shall be equal to the sum of thenumber of SPACEs and of the number of digits, plus4; or only 3 if the sign of the signifi
45、cand is represented by SPACE; or only 2 if the latter SPACE has been omitted. In an unsigned NR3 the value represented shall be greater than, or equal to, zero. In a signed NR3 the PLUS SIGN of the significand can be replaced by a SPACE. If the exponent has the value zero, its sign shall be a PLUS S
46、IGN. If the exponent is not equal to zero and if its sign is omitted, then the exponent is positive. The representation of the numerical value zero shall contain a PLUS SIGN or a SPACE, only ZEROs in the significand, and a PLUS SIGN and only ZEROs in the exponent. 8.4 Examples In the following examp
47、les, the field length is assumed to be eight. Common notation Unsigned-NR2 Signed-NR2 1327. 1327.000 0001327. %1327. +1327.00 %+1327. %1327. 123,45 00123,45 %123,45 %+123,45 %123,45 1237,0 %1237,0 %+1237,0 %1237,0 .00001 00.00001 +0.00001 5,678 no representation 5,67800 05,6780 1234,567 1234,567 no
48、representation 0 000,0000 %0,0 +0,00000 %+0,0 %0,0 %0, NR3 = unsigned-NR3/signed-NR3 unsigned-NR3 = space* significand exponent-mark exponent signed-NR3 = space* (sign/space) significand exponent-mark exponent significand = (digitdigit* decimal-mark digit*)/(digit* decimal-mark digitdigit*) exponent
49、 = sign? digitdigit*BS 6727:1987 4 BSI 12-1999 Table 3 Examples of NR3 8.5 Normalized form An NR3 representation, in which the significand shall be a proper fraction in the range 0,1 u ABS (s) 1 where ABS (s) shall be the unsigned value of the significand, is said to be normalized form. This condition may be met by appropriate selection of the value represented by the exponent. Any given number can be represented by a unique normalized form. For example, the normalized representatio