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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham 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-02-27 10:28:09 PST Newsgroups: comp.lang.ada Path: nntp.gmd.de!news.rwth-aachen.de!news.rhrz.uni-bonn.de!RRZ.Uni-Koeln.DE!uni-duisburg.de!zib-berlin.de!Germany.EU.net!EU.net!chsun!mlma11.matrix.ch!user From: Mats.Weber@matrix.ch (Mats Weber) Subject: Re: Rational/Verdix Number Bug Message-ID: Sender: usenet@eunet.ch Organization: ELCA Matrix SA References: <3i0nip$b55@rational.rational.com> <3il66m$ps1@jabba.ess.harris.com> Date: Mon, 27 Feb 1995 18:28:09 GMT Date: 1995-02-27T18:28:09+00:00 List-Id: 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;