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=2.1 required=5.0 tests=BAYES_05,INVALID_DATE, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!ames!sdcsvax!ucbvax!WPAFB-JALCF.ARPA!seafac From: seafac@WPAFB-JALCF.ARPA.UUCP Newsgroups: comp.lang.ada Subject: (none) Message-ID: <8706041655.AA23291@ucbvax.Berkeley.EDU> Date: Thu, 4-Jun-87 12:21:00 EDT Article-I.D.: ucbvax.8706041655.AA23291 Posted: Thu Jun 4 12:21:00 1987 Date-Received: Sat, 6-Jun-87 08:20:32 EDT Sender: daemon@ucbvax.BERKELEY.EDU Reply-To: " ASD/ENASF" Distribution: world Organization: The ARPA Internet List-Id: DEC Ada Problem Report from: Mr. Gary Sivak (513) 255-3586 ASD/ENASF wright-Patterson Air Force Base, Ohio 45433-6503 There seems to be a problem with the way the VAX-hosted DEC-Ada compiler V1.3-24 handles SHORT_INTEGER variables. Explanation. In VAX Ada, the SHORT_INTEGER is defined as a 16-bit two's complement number with the sign bit, in the left-most position, set to 1 for negative values. For example, for 3-bit arithmetic we have: NUMERIC_VALUE BIT_REPRESENTATION -4 100 -3 101 -2 110 -1 111 0 000 1 001 2 010 3 011 The valid range of two's complement 3-bit numbers is thus -4 through +3. Similarly, the range of 16-bit two's complement numbers is -32,768 through +32,767. Problem. One can store the minimum value -32,768 into a SHORT_INTEGER variable with a GET instantiated for SHORT_INTEGER, but you cannot do it Via an assignment statement. The exception NUMERIC_ERROR is raised when you try. The minimal value an assignment statement will accept is -32,767. The following simple source code and test results demonstrate the problem: with TEXT_IO; use TEXT_IO; with SHORT_INTEGER_TEXT_IO; use SHORT_INTEGER_TEXT_IO; procedure TEST_READ is INPUT_VALUE : SHORT_INTEGER; begin --TEST_READ loop PUT("Enter INPUT_VALUE. "); GET(INPUT_VALUE); NEW_LINE; PUT(INPUT_VALUE); NEW_LINE; end loop; end TEST_READ; RUN TEST_READ Enter INPUT_VALUE. 32767 32767 Enter INPUT_VALUE. -32767 -32767 Enter INPUT_VALUE. -32768 -32768 Enter INPUT_VALUE. *INTERRUPT* with TEXT_IO; use TEXT_IO; with SHORT_INTEGER_TEXT_IO; use SHORT_INTEGER_TEXT_IO; procedure TEST_ASSIGN is INPUT_VALUE : SHORT_INTEGER; begin --TEST_ASSIGN INPUT_VALUE := -32768; NEW_LINE; PUT(INPUT_VALUE); NEW_LINE; end TEST_ASSIGN; $ RUN TEST_ASSIGN %ADA-I-NUMERIC_ERROR, NUMERIC_ERROR %SYSTEM-F-INTDIV, arithmetic trap, integer divide by zero at PC=00000848, PSL=03C000A6 %TRACE-E-TRACEBACK, symbolic stack dump follows module name routine name line rel PC abs PC 0000D1D6 0000D1D6 ----- above condition handler called with exception 00000484: %SYSTEM-F-INTDIV, arithmetic trap, integer divide by zero at PC=00000848, PSL=03C000A6 ----- end of exception message TEST_ASSIGN TEST_ASSIGN 7 00000012 00000848 ADA$ELAB_TEST_A ADA$ELAB_TEST_ASSIGN 00000009 00000609 000008D9 000008D9 0000CFD2 0000CFD2 ADA$ELAB_TEST_A ADA$ELAB_TEST_ASSIGN 0000001B 0000061B 000008B4 000008B4 if anyone knows why you can get but not assign, please let me know. gary Sivak ------