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-Thread: 103376,91965a012526b259 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!fu-berlin.de!uni-berlin.de!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Float to String Date: Tue, 9 Nov 2004 09:39:42 +0100 Message-ID: <526nxsbun7e2.1n5a4jpe7u7ww$.dlg@40tude.net> References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de IDCY55zuAL5mhlquYn4VawX5BgQLdEpV7vYG4nVVT+8AZSBpQ= User-Agent: 40tude_Dialog/2.0.12.1 Xref: g2news1.google.com comp.lang.ada:6072 Date: 2004-11-09T09:39:42+01:00 List-Id: On 08 Nov 2004 18:06:04 +0100, Pascal Obry wrote: > I was wondering if there is a way to save a float into a string and read it > back without loosing precision ? > > I tried something like: > > F_Str : String (1 .. Float'Base'Digits); > > Float_Text_IO.Put (F_Str, My_Float, Aft => Float'Base'Digits); > > But this is not enough... Ideas ? There is no any portable way to do so. Floating-point numbers are intended to be imprecise. Normally the application domain should determine the required accuracy. It is definitely possible to maintain that accuracy during I/O conversions. What is impossible and meaningless, is to try to define the *application-specific* accuracy as "the ultimate accuracy of Float on this concrete machine for this concrete compiler". Another question is asymptotic behavior of repeated forth and back conversions. I would not expect that its error is unbounded, however ARM is silent about that. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de