From: Marius Amado Alves <amado.alves@netcabo.pt>
To: comp.lang.ada@ada-france.org
Subject: Re: Float to String
Date: Wed, 10 Nov 2004 18:02:44 +0000
Date: 2004-11-10T18:02:44+00:00 [thread overview]
Message-ID: <mailman.91.1100109775.10401.comp.lang.ada@ada-france.org> (raw)
In-Reply-To: <ubre5abvs.fsf@obry.org>
>>Float'Image (Float_Value)
>>and
>>Float'Value (String_Holding_The_Previous)
>
> That's the problem, you loose quite a bit of precision with these convertions.
I just came across an example:
I have 64 bits available, so I define a 15 digits float
type Float_64 is
digits 15
range -16#0.FFFF_FFFF_FFFF_F8#E+256
.. 16#0.FFFF_FFFF_FFFF_F8#E+256;
for Float_64'Size use 64;
Now I want to know the range in decimal (because the users will be
inputing in decimal). I use 'Image on 'First and 'Last:
First :-1.79769313486232E+308
Last : 1.79769313486232E+308
Now I rewrite the type definition to make it selfdocumenting:
type Float_64 is
digits 15
range -1.79769313486232E+308
.. 1.79769313486232E+308;
for Float_64'Size use 64;
But now GNAT complaints that the size is too small, minimum allowed is 96!
Decrementing the last digit
range -1.79769313486231E+308
.. 1.79769313486231E+308;
makes it pass.
The culprit is probably the fact that approximations are in the
direction away from zero.
And GNAT says 96 bits (and not 65) probably because of alignment
requirements.
Anyway, just an illustration of how reconversions between systems (hexa
and decimal) can be disruptive.
next prev parent reply other threads:[~2004-11-10 18:02 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-11-08 17:06 Float to String Pascal Obry
2004-11-08 18:29 ` Jean-Pierre Rosen
2004-11-08 19:03 ` Jeffrey Carter
2004-11-08 20:13 ` David C. Hoos
2004-11-08 20:18 ` David C. Hoos
2004-11-09 0:40 ` John B. Matthews
2004-11-09 5:24 ` David C. Hoos, Sr.
2004-11-08 21:29 ` Nick Roberts
2004-11-09 17:58 ` Peter Hermann
2004-11-10 9:38 ` Peter Hermann
2004-11-10 12:12 ` Larry Kilgallen
2004-11-09 8:39 ` Dmitry A. Kazakov
2004-11-09 18:17 ` Pascal Obry
2004-11-10 8:53 ` Dmitry A. Kazakov
2004-11-10 11:15 ` Samuel Tardieu
2004-11-10 14:35 ` Dmitry A. Kazakov
2004-11-10 15:00 ` Peter Hermann
2004-11-10 15:35 ` Marius Amado Alves
2004-11-10 16:35 ` Dmitry A. Kazakov
2004-11-10 17:28 ` Marius Amado Alves
2004-11-11 15:25 ` Dmitry A. Kazakov
2004-11-11 16:40 ` Marius Amado Alves
2004-11-11 18:31 ` Dmitry A. Kazakov
2004-11-11 22:27 ` Marius Amado Alves
2004-11-12 12:19 ` Dmitry A. Kazakov
2004-11-12 14:55 ` Marius Amado Alves
2004-11-10 5:05 ` Steve
2004-11-10 15:37 ` Pascal Obry
2004-11-10 16:29 ` Alex R. Mosteo
2004-11-10 16:48 ` Pascal Obry
2004-11-10 18:02 ` Marius Amado Alves [this message]
2004-11-10 19:40 ` Jeffrey Carter
2004-11-10 21:04 ` Marius Amado Alves
2004-11-11 3:33 ` Steve
2004-11-11 7:51 ` tmoran
2004-11-11 12:32 ` Pascal Obry
2004-11-11 15:53 ` David C. Hoos, Sr.
2004-11-11 16:17 ` Pascal Obry
2004-11-11 17:36 ` Jeffrey Carter
2004-11-12 0:01 ` David C. Hoos, Sr.
2004-11-12 0:30 ` Jeffrey Carter
2004-11-11 12:30 ` Pascal Obry
2004-11-13 16:37 ` Ginduskina
2004-11-13 18:41 ` Björn Lundin
2004-11-13 16:39 ` Ginduskina
2004-11-13 16:49 ` Simon Wright
2004-11-13 16:53 ` David C. Hoos, Sr.
2004-11-13 16:55 ` Pascal Obry
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox