J3/98-111 Date: 29 Jan 1998 To: J3 From: Dick Hendrickson Subject: 4d: control of I/O rounding, specs and syntax This is the Specs for item 4d, Control of I/O Rounding, for Interval Arithmetic Enabling Technologies. Assuming there is general agreement, I think this is detailed enough to also be the syntax document. The basic idea is to add new rounding control facilities modeled after BN and BZ. They will control the way a processor must round real and complex values for F, E, EN, ES, D, and G formatting, both on input and on output. There are 4 modes provided: DRU Round up DRD Round down DRZ Round to zero DRN Round to nearest The intent is to mimic the IEEE rounding modes, but not actually require IEEE arithmetic. We'll need explicit words to say that, for example, DRU must produce an internal value that is greater than or equal to the input character string or a character value that is greater than or equal to the internal value. We don't want to force any particular accuracy requirements, just the bounds. Directed rounding only applies to files connected for formatted I/O. There are 4 areas that need to be changed. OPEN Add a new connect-spec (R905) ROUND = scalar-default-char-expression The expression shall be one of "DRU", "DRD", "DRZ", or "DRN" This specifies the initial rounding for a file connection. If no ROUND= is present, the rounding mode is processor dependent. It's not clear to me what this means. Do we want the processor to pick one of the above methods and use it all of the time? Or can it use a proprietary method that isn't exactly any of the above? INQUIRE Add a new inquire-spec (R924) ROUND = scalar-default-char-variable Lets you find out the rounding mode in effect. Returns one of the above strings, or "UNDEFINED" if not specified on the OPEN READ/WRITE Add round-edit-desc to the format control-edit-desc (R1010) with the four above possible values. It wraps around when a closing parenthesis is reached just like other control edit descriptors. Like BN, once you start using a rounding mode in a format there is no way to return to the default. DERIVED TYPE I/O The current rounding mode is one more item (like BN, SS...) that needs to be saved when a user derived type I/O routine is entered and restored when it exits. It's unclear to me whether the rounding mode is set to the processor default value or to the OPENed value when the user routine is called. We should do it the way the similar descriptors are handled. Potential straw votes. 1) Should we provide all 4 (only the first 2 are really needed for interval arithmetic) 2) Should we provide more? 3) Should we define the processor default? 4) Should we spell "DRU" "differently" (if so, how do we spell the others?) 5) Should we add "none of the above" as a result for INQUIRE when the processor uses a proprietary method or should we require the processor to use one of these methods? 6) On OPEN should ROUND be ignored for unformatted I/O or should it be an error? 7) Should INQUIRE return UNDEFINED if the OPEN didn't specify a method or may it return one of the above if that's what it actually uses? 8) Should INQUIRE return UNDEFINED if the file wasn't opened for formatted I/O? 9) What should the mode be when a user derived type I/O routine is entered?