comp.lang.ada
 help / color / mirror / Atom feed
From: Mats.Weber@matrix.ch (Mats Weber)
Subject: Re: Rational/Verdix Number Bug
Date: Mon, 27 Feb 1995 18:28:09 GMT
Date: 1995-02-27T18:28:09+00:00	[thread overview]
Message-ID: <Mats.Weber-2702951928090001@mlma11.matrix.ch> (raw)
In-Reply-To: 3il66m$ps1@jabba.ess.harris.com

In article <3il66m$ps1@jabba.ess.harris.com>, azimmer@rsa.hisd.harris.com wrote:

> Well, I am in a perplexing situation.  I tried this when I first heard
> about the problem and duplicated it with a program like the one attached.
> I just tried it and  I could not duplicate it.  I am running SunAda 1.1(j)
> on a SPARC LX.  Below is the test program.
> 
> with text_io;
> procedure test_float is
>   test : float := 2147.486348;
>   package flt_io is new text_io.float_io(float);
> begin
>   flt_io.put(test);
>   text_io.new_line;
>   flt_io.put(test * 2.0);
>   text_io.new_line;
>   flt_io.put(test / 2.0);
> end test_float;

Here, except in the implicit converion of the literal 2147.486348 from
universal_real to float, you only use floating point arithmetic (the basic
operations of the predefined type float), not the compiler's internal
infinite precision arithmetic, which is where the bug is from my
understanding of the problem.

You should try this instead:

 with text_io;
 procedure test_float is
   test : constant := 2147.486348;
   double_test : constant := 2.0 * test;
   half_test : constant := test / 2.0;
   package flt_io is new text_io.float_io(float);
 begin
   flt_io.put(test);         -- implicit conversion universal_real -> float
   text_io.new_line;
   flt_io.put(double_test);  -- idem
   text_io.new_line;
   flt_io.put(half_test);    -- idem
 end test_float;



  reply	other threads:[~1995-02-27 18:28 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <3i0nip$b55@rational.rational.com>
1995-02-24 17:49 ` Rational/Verdix Number Bug Alan D Zimmerman
1995-02-27 18:28   ` Mats Weber [this message]
1995-03-01 18:21     ` Kent Mitchell
1995-03-02 13:49     ` Alan D Zimmerman
replies disabled

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