From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!zaphod.mps.ohio-state.edu!sdd.hp.com!apollo!apollo.hp.com!tedg From: tedg@apollo.HP.COM (Ted Grzesik) Newsgroups: comp.lang.ada Subject: float constraint checks Message-ID: <1991Jun12.190054.27094@apollo.hp.com> Date: 12 Jun 91 19:00:54 GMT Sender: netnews@apollo.hp.com (USENET posting account) Organization: Hewlett-Packard Company, Chelmsford, MA Nntp-Posting-Host: skier.ch.apollo.hp.com List-Id: 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)