comp.lang.ada
 help / color / mirror / Atom feed
* Exception on System.Max_Digits
@ 1998-01-30  0:00 K. E. Garlington
  1998-01-30  0:00 ` Tucker Taft
  1998-02-01  0:00 ` Robert Dewar
  0 siblings, 2 replies; 6+ messages in thread
From: K. E. Garlington @ 1998-01-30  0:00 UTC (permalink / raw)



We have a case where two Ada83 compilers provide different results, and
we are trying to decide which is correct.

Both compilers have System.Max_Digits = 15. When we use Float_IO
to read the number

   -2627.097925618800

one vendor raises a Constraint_Error, the other doesn't. The vendor
of the compiler raising the error says that it is because the number
has too many digits; removing the final zero causes the exception to
be avoided. The other vendor accepts the number.

Is either vendor wrong?

Also, will System.Max_Digits apply to any floating-point type?




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

* Re: Exception on System.Max_Digits
  1998-01-30  0:00 K. E. Garlington
@ 1998-01-30  0:00 ` Tucker Taft
  1998-02-01  0:00 ` Robert Dewar
  1 sibling, 0 replies; 6+ messages in thread
From: Tucker Taft @ 1998-01-30  0:00 UTC (permalink / raw)



K. E. Garlington (Kennie.E.Garlington@nospam.lmco.com) wrote:

: We have a case where two Ada83 compilers provide different results, and
: we are trying to decide which is correct.

: Both compilers have System.Max_Digits = 15. When we use Float_IO
: to read the number

:    -2627.097925618800

: one vendor raises a Constraint_Error, the other doesn't. The vendor
: of the compiler raising the error says that it is because the number
: has too many digits; removing the final zero causes the exception to
: be avoided. The other vendor accepts the number.

: Is either vendor wrong?

The vendor whose compiler raises Constraint_Error is wrong (based
on the information you give above).  You might ask the vendor
to quote chapter and verse of the reference manual to justify
why Constraint_Error is being raised.  I can say fairly
confidently that there is no run-time constraint check in Ada 83 
or Ada 95 that is somehow related to System.Max_Digits.

You are allowed to give as many digits in a real numeral as you want
on input to Float_IO.Get.  The value of Max_Digits is unrelated
to this.  Max_Digits indicates the number of digits of 
precision kept internally in the most precise floating point type.  
The parameter "Width" to Get limits the number of digits that
are looked at, but you should still never get Constraint_Error
due to overrunning the Width.  Float_IO.Get will simply ignore
the extra digits.

The only justification for Constraint_Error would be if the *value* of
the number exceeds the base range of the floating point type.  The
number of digits is irrelevant.  Given the typical algorithm
for converting an external representation for a floating point
number into an internal representation, one might expect
the algorithm to raise Constraint_Error if the number of digits was
so great that the value of the number you get if you ignore the
decimal point (or pretend it is all the way on the right) was
beyond (Long_)Float'Last.  But on a typical IEEE machine, that would be
more like 38 digits.  A smarter algorithm simply ignores
digits after a certain number because they would have no effect on
the final result.

: Also, will System.Max_Digits apply to any floating-point type?

It represents the precision of the most precise floating point type.
It is unrelated to the number of digits allowed on input
to Float_IO.Get.  There should be no practical limit on that.

--
-Tucker Taft   stt@inmet.com   http://www.inmet.com/~stt/
Intermetrics, Inc.  Burlington, MA  USA




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

* Re: Exception on System.Max_Digits
  1998-01-30  0:00 K. E. Garlington
  1998-01-30  0:00 ` Tucker Taft
@ 1998-02-01  0:00 ` Robert Dewar
  1998-02-01  0:00   ` Ken Garlington
  1 sibling, 1 reply; 6+ messages in thread
From: Robert Dewar @ 1998-02-01  0:00 UTC (permalink / raw)



Ken asks

<<Both compilers have System.Max_Digits = 15. When we use Float_IO
to read the number

   -2627.097925618800

one vendor raises a Constraint_Error, the other doesn't. The vendor
of the compiler raising the error says that it is because the number
has too many digits; removing the final zero causes the exception to
be avoided. The other vendor accepts the number.
>>

A truly surprising bug, it is of course the case that input numbers can
have any number of digits (and having to handle this in Float_IO can
be a bit annoying). The ACVC certainly tests for this, so I guess the
compiler which raised Constraint_Error must not be validated???





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

* Re: Exception on System.Max_Digits
  1998-02-01  0:00 ` Robert Dewar
@ 1998-02-01  0:00   ` Ken Garlington
  0 siblings, 0 replies; 6+ messages in thread
From: Ken Garlington @ 1998-02-01  0:00 UTC (permalink / raw)



Robert Dewar wrote:
> 
> Ken asks
> 
> <<Both compilers have System.Max_Digits = 15. When we use Float_IO
> to read the number
> 
>    -2627.097925618800
> 
> one vendor raises a Constraint_Error, the other doesn't. The vendor
> of the compiler raising the error says that it is because the number
> has too many digits; removing the final zero causes the exception to
> be avoided. The other vendor accepts the number.
> >>
> 
> A truly surprising bug, it is of course the case that input numbers can
> have any number of digits (and having to handle this in Float_IO can
> be a bit annoying). The ACVC certainly tests for this, so I guess the
> compiler which raised Constraint_Error must not be validated???

I'll check on the validation status (of course, this is an Ada83
compiler,
so I'm not sure what kind of answer I'll get). Does anyone know the
specific
ACVC test(s) that apply?




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

* Re: Exception on System.Max_Digits
@ 1998-02-05  0:00 Dan Lehman
  0 siblings, 0 replies; 6+ messages in thread
From: Dan Lehman @ 1998-02-05  0:00 UTC (permalink / raw)



Please name the compiler(s) involved here (seems like relevant information
omitted from the question, surely!).

---Dan
------- *
 





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

* Re: Exception on System.Max_Digits
@ 1998-02-05  0:00 Dan Lehman
  0 siblings, 0 replies; 6+ messages in thread
From: Dan Lehman @ 1998-02-05  0:00 UTC (permalink / raw)



> The ACVC certainly tests for this

Not so certainly at all--l00k and show us where?!

There seem to be no specific Float_IO tests that use large numerals
--they're not really so keen on that aspect of conformity, rather
simply checking that things are in place (so, small, easy model
numbers get used--occasionally non-model #s, too, which show up
on disputes! :-).

The only case of longggg numerals that I have found is in tests
that check for exact representations of 'Large/'Small (though one
might expect the bogus argument about too many numerals to be
offered there as well :-).

---Dan
------- *





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

end of thread, other threads:[~1998-02-05  0:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-02-05  0:00 Exception on System.Max_Digits Dan Lehman
  -- strict thread matches above, loose matches on Subject: below --
1998-02-05  0:00 Dan Lehman
1998-01-30  0:00 K. E. Garlington
1998-01-30  0:00 ` Tucker Taft
1998-02-01  0:00 ` Robert Dewar
1998-02-01  0:00   ` Ken Garlington

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