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.3 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,937456e2dd44bde1 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-08-12 06:09:02 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!colt.net!easynet-quince!easynet.net!teaser.fr!enst.fr!not-for-mail From: "David C. Hoos" Newsgroups: comp.lang.ada Subject: Re: Floating point representation-help Date: Mon, 12 Aug 2002 08:08:13 -0500 Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: References: <14763faf.0208120429.658b842d@posting.google.com> Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Trace: avanie.enst.fr 1029157742 82024 137.194.161.2 (12 Aug 2002 13:09:02 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Mon, 12 Aug 2002 13:09:02 +0000 (UTC) Return-Path: X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0.12 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: comp.lang.ada mail<->news gateway List-Unsubscribe: , Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Original-Cc: vashwathus@yahoo.com Xref: archiver1.google.com comp.lang.ada:27950 Date: 2002-08-12T08:08:13-05:00 ----- Original Message ----- From: "Ashwath" Newsgroups: comp.lang.ada To: Sent: Monday, August 12, 2002 7:29 AM Subject: Floating point representation-help > Have look at the following program > with TEXT_IO; > with UNCHECKED_CONVERSION; > procedure UNCHECK_DEMO is > package INT_IO is new TEXT_IO.INTEGER_IO(LONG_LONG_INTEGER); > function INT_TO_FLT is > new UNCHECKED_CONVERSION( > SOURCE => LONG_LONG_INTEGER, > TARGET => FLOAT); > INT : LONG_LONG_INTEGER; > FLT : FLOAT; > begin > INT:=2#11111111100000000000000000000000#; > FLT:=INT_TO_FLT(INT); > INT_IO.put(INT,0,2); > end; First, You have not specified which compiler and platform you're using, and things of this nature may be both platform- _and_ compoler-dependent. Second, the above program does not compile with GNAT on Linux, for several reasons, one of which is that the size of Long_Long_Integer on that compiler and platform is not the same as the size of Float on that compiler and platform. The following program does compile, and shows that the value of Flt is indeed infinity. There is nothing that says that computing a value of inifinity with IEEE Floating point representation should raise an exception, since +inf, -Inf, and NaN are all legal IEEE Floating values. However, performing a computation with such a value as an operand should raise an exception. with Interfaces; with Text_IO; with Unchecked_Conversion; procedure Uncheck_Demo is function Int_To_Flt is new Unchecked_Conversion (Source => Interfaces.Unsigned_32, Target => Float); Int : Interfaces.Unsigned_32; Flt : Float; begin Int:=2#11111111100000000000000000000000#; Flt:=Int_To_Flt(Int); Text_IO.Put_Line (Float'Image (Flt)); end; Furthermore, in my modified version of your program, there is still something that may be compiler-, and/or platform-dependent -- i.e., the declaration of Flt as type Float. There is no guarantee that every compiler on every platform defines the type Float as 32-bit IEEE floating point. The GNAT compiler does make types available that re 32- and 64- bit IEEE floating point on platforms where the underlying hardware supports it.