2008/4/27 John P. Baker <[EMAIL PROTECTED]>: > In many cases, the user may simply specify 1.75E+6, the context will > determine both the format and the length, and everything will be fine. > > However, there are other computational situations where the use of a > particular format and/or length is important, and the choice of an incorrect > format and/or length may result in miniscule computational errors, which > then grow into significant errors through a subsequent series of > computations. > > It is therefore necessary that the capability to specify formats and lengths > be present. > > I am currently considering suffix characters of "B" (binary), "D" (decimal), > and "H" (hexadecimal). > > However, I need to come up with a scheme for the specification of length. > "S" (single) and "Q" (quad) would seem to work, but "D" (double) would > already be in use as "D" (decimal).
This is a big can o' worms. Programming languages vary so much in their syntax and semantics that I doubt you'll be able to come up with anything compatible with all. But if I may make a couple of points: So far all this seems to assume that the number (or components thereof) will be written in decimal. Since two of the three representations under discussion are not decimal based, surely you should allow for hex or binary specification of the number or components. Names like single, double, and quad are sure to be interpreted differently by different people, languages, and hardware architectures. I'd suggest specifying the number of digits of the base in use. PL/I allows the specification of what it calls base (BINARY or DECIMAL), scale (FLOAT or FIXED), precision (significant digits and decimal-point placement), and mode (REAL or COMPLEX). Unfortunately it doesn't, to my knowledge, allow for multiple kinds of FLOAT BINARY representation, or put another way, for FLOAT HEXADECIMAL. In any case, there is no way to specify these attributes in detail for a constant; the above are for variable declarations. (Well, modern PL/I has declared constants, but they are not syntactically different from preinitialized variables.) Another approach to consider for constants is APL's idea of Representation and Base Value. These are well summarized at http://www.sigapl.org/encode.htm . APL adds the intriguing concept of mixed bases, the classic example of which is the pre-decimal UK pounds, shillings, and pence currency. I doubt we'll see that in hardware any time soon, however... Tony H. ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [EMAIL PROTECTED] with the message: GET IBM-MAIN INFO Search the archives at http://bama.ua.edu/archives/ibm-main.html

