comp.lang.ada
 help / color / mirror / Atom feed
* float constraint checks
@ 1991-06-12 19:00 Ted Grzesik
  1991-06-12 21:16 ` Robert I. Eachus
  0 siblings, 1 reply; 3+ messages in thread
From: Ted Grzesik @ 1991-06-12 19:00 UTC (permalink / raw)


I have a question regarding constraint checks of floating point assignments.

The LRM (3.5.7) does not make it clear to me whether my compiler is failing to give a CONSTRAINT_ERROR in the following situation:

Note: some code not shown.


with text_io;

procedure float_test is

   package short_float_io is new text_io.float_io ( short_float );
   package long_float_io is new text_io.float_io (float );
   package int_io is new text_io.integer_io (integer);
 
   value,  value1,  value2   : short_float;
   lvalue, lvalue1, lvalue2  : float;

   begin
       .
       .
       .

     value := short_float(-9.0E-150);
     text_io.put( "The value of -9.0E-150 is " );
     short_float_io.put ( value );
     text_io.new_line;

     value  := short_float(-9.0E-38);
     value1 :=  short_float(9.0E-38);
     value2 :=  value * value1;
     text_io.put ( "The value of -9.0E-37 * 9.0E-37 is ");
     short_float_io.put( value2 );
     text_io.new_line;

     lvalue  := float(-9.0E-500);
     text_io.put ( " The value of -9.0E-500 is " );
     long_float_io.put ( lvalue );
     text_io.new_line;

     lvalue  := float(-9.0E-500);
     lvalue1 :=  float(9.0E-500);
     lvalue2 :=  lvalue * lvalue1;
     text_io.put ( " The value of -9.0E-500 * -9.0E-500 is " );
     long_float_io.put( lvalue2 );
     text_io.new_line;

   end float_test;

Execution results:

Attributes for short_float:
DIGITS:           6
MANTISSA:          21
EPSILON:  9.53674316406250E-07
EMAX:          84
SMALL:  2.58493941422821E-26
LARGE:  1.93428038904620E+25
SAFE_EMAX:         126
SAFE_SMALL:  5.87747175411144E-39
SAFE_LARGE:  8.50705511654154E+37
Attributes for float:
DIGITS:          15
MANTISSA:          51
EPSILON:  8.88178419700125E-16
EMAX:         204
SMALL:  1.94469227433161E-62
LARGE:  2.57110087081438E+61
SAFE_EMAX:        1022
SAFE_SMALL:  1.11253692925360E-308
SAFE_LARGE:  4.49423283715579E+307
The value of -9.0E-150 is  0.00000E+00
The value of -9.0E-37 * 9.0E-37 is  0.00000E+00
 The value of -9.0E-500 is  0.00000000000000E+00
 The value of -9.0E-500 * -9.0E-500 is  0.00000000000000E+00

-- 
Ted Grzesik       Massachusetts Language Lab             Hewlett-Packard Company
tedg@apollo.hp.com                          Chelmsford, MA  (508) 256-6600 x5959
"Civilization is the limitless multiplication of unnecessary necessities."
                                       -- Mark Twain (Samuel Clemens)

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

end of thread, other threads:[~1991-06-14 17:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <190054@<1991Jun12>
1991-06-14 17:23 ` float constraint checks stt
1991-06-12 19:00 Ted Grzesik
1991-06-12 21:16 ` Robert I. Eachus

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