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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: 32-bit float and 64-bit float Date: Mon, 14 Aug 2017 08:55:19 +0200 Organization: Aioe.org NNTP Server Message-ID: References: NNTP-Posting-Host: vZYCW951TbFitc4GdEwQJg.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 X-Notice: Filtered by postfilter v. 0.8.2 Content-Language: en-US Xref: news.eternal-september.org comp.lang.ada:47720 Date: 2017-08-14T08:55:19+02:00 List-Id: On 14/08/2017 00:29, Victor Porton wrote: > What is the best way to define in Ada types which are expected to contain: > > 1. 64-bit floating point numbers (incl. ±Inf, ±0, NaN); > > 2. 32-bit floating point numbers (incl. ±Inf, ±0, NaN). There is no way since you specified neither the precision and range nor the floating-point representation format IEEE 754, IBM, DEC etc. Ada's way is the former. The latter is not possible in general. If you have a requirement to support a specific representation, e.g. for I/O you have to convert it forth and back to an Ada type most close to it. In Simple Components there are packages to convert IEEE 754 floats: http://www.dmitry-kazakov.de/ada/components.htm#IEEE_754 -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de