comp.lang.ada
 help / color / mirror / Atom feed
* I/O question
@ 1993-03-29 21:34 Ron Sercely
  1993-03-29 23:20 ` Mark A Biggar
  0 siblings, 1 reply; 2+ messages in thread
From: Ron Sercely @ 1993-03-29 21:34 UTC (permalink / raw)


Could someone tell me what is supposed to happen with this code?

with TEXT_IO;
use  TEXT_IO;
procedure PR30787 is
   type X_TYPE is digits 15;
   package MY_IO is new FLOAT_IO(X_TYPE);
   use  MY_IO;
   X : X_TYPE := (-5000001.84);
begin
   PUT(X, 1, 15, 2);
   NEW_LINE;
end PR30787;

On Convex Ada, the PUT raises LAYOUT_ERROR.  This seems reasonable given that
the RM specifically states that the '-' sign counts as a character, and then
the '5' digit that should be output to the left of the decimal point means that
"-5" will not fit in a "fore" of 1.  On the other hand, although the RM
(14.3.5(10) states:
	"The exception LAYOUT_ERROR is raised by a PUT procedure that outputs
to a parameter of type STRING, if the length of the actual string is
insufficient for the output of the item".
I can't find where the RM states that LAYOUT_ERROR should be raised when the
length of a portion of formatted output will not fit into a field of the
output, and of course, strictly speaking, this is not output to a parameter
of type string.

Dec Ada on the other hand prints out the value -5.00000184 without raising an
exception.  

What is "correct".



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: I/O question
  1993-03-29 21:34 I/O question Ron Sercely
@ 1993-03-29 23:20 ` Mark A Biggar
  0 siblings, 0 replies; 2+ messages in thread
From: Mark A Biggar @ 1993-03-29 23:20 UTC (permalink / raw)


In article <1993Mar29.213438.25890@convex.com> sercely@convex.com (Ron Sercely) writes:
>   type X_TYPE is digits 15;
>   package MY_IO is new FLOAT_IO(X_TYPE);
>   X : X_TYPE := (-5000001.84);
>begin
>   PUT(X, 1, 15, 2);
>On Convex Ada, the PUT raises LAYOUT_ERROR.  This seems reasonable given that
>the RM specifically states that the '-' sign counts as a character, and then
>the '5' digit that should be output to the left of the decimal point means that
>"-5" will not fit in a "fore" of 1.  On the other hand, although the RM
>(14.3.5(10) states:
>	"The exception LAYOUT_ERROR is raised by a PUT procedure that outputs
>to a parameter of type STRING, if the length of the actual string is
>insufficient for the output of the item".
>I can't find where the RM states that LAYOUT_ERROR should be raised when the
>length of a portion of formatted output will not fit into a field of the
>output, and of course, strictly speaking, this is not output to a parameter
>of type string.
>Dec Ada on the other hand prints out the value -5.00000184 without raising an
>exception.  

The Dec compiler appears to be correct.  The last sentence of RM(14.3.5(7))
says:

"The format given a PUT procedure is overridden if it is insufficiently wide."

Which I interpret to mean, go back to the default if a field is not wide 
enough.  But, I guess it could mean other things as well.  For example,
ti could be interpreted to mean override the whole format specification,
or is could mean override just the parts that are undersized.  In any case,
it appears to be a bug to raise LAYOUT_ERROR in your example.

--
Mark Biggar
mab@wdl1.wdl.loral.com






^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1993-03-29 23:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1993-03-29 21:34 I/O question Ron Sercely
1993-03-29 23:20 ` Mark A Biggar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox