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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,5cc99ba8cc92b94d X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1995-03-02 05:52:21 PST Path: bga.com!news.sprintlink.net!cs.utexas.edu!swrinde!gatech!darwin.sura.net!jabba.ess.harris.com!usenet From: azimmer@rsa.hisd.harris.com (Alan D Zimmerman) Newsgroups: comp.lang.ada Subject: Re: Rational/Verdix Number Bug Date: 2 Mar 1995 13:49:51 GMT Organization: Loral Space & Range Systems Message-ID: <3j4idv$14u@jabba.ess.harris.com> References: Reply-To: azimmer@rsa.hisd.harris.com NNTP-Posting-Host: yoda.rsa.hisd.harris.com Date: 1995-03-02T13:49:51+00:00 List-Id: In article , Mats.Weber@matrix.ch (Mats Weber) writes: > 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. No, actually the problem is that I reversed the 3 and the six. With the following program, I get the proper (incorrect) results: Program: with text_io; procedure test_float is test : float := 2147.483648; 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; Results: -2.14748364800000E+03 -4.29496729600000E+03 -1.07374182400000E+03 For what it is worth, I have been told that rational knows about this and that a patch is available. Thanks to Richard Hash of Team-Ada who pointed out my problem. Alan -- | Alan D. Zimmerman | Eagle Scout | | azimmer@rsa.hisd.harris.com | Scoutmaster T324 | |-------------------------------------------------------------------| | All opinions are solely my own and do not represent Loral | | On My Honor I will do my best... |