From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: How to round to the nearest fixed-point value?
Date: Fri, 24 Jan 2014 16:47:55 -0600
Date: 2014-01-24T16:47:55-06:00 [thread overview]
Message-ID: <lbuqir$599$1@loke.gir.dk> (raw)
In-Reply-To: lbupic$4pd$1@loke.gir.dk
>> In case anyone is interested, the following rewrite works around the
>> problem:
>>
>> function Convert (Value : High) return Low is
>> begin
>> return Low'Round (Value * 1.0);
>> end Convert;
To clarify a bit, I think this operates identically to:
function Convert (Value : High) return Low is
begin
return Low'Round (Long_Float(Value));
end Convert;
which probably works around any GNAT bug but also is injecting the
possibility of floating point precision issues into your code. So I'm not
sure it is a good idea (if Long_Float has enough bits, it might not matter).
Randy.
next prev parent reply other threads:[~2014-01-24 22:47 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-22 16:48 How to round to the nearest fixed-point value? Natasha Kerensikova
2014-01-22 17:53 ` G.B.
2014-01-22 22:26 ` adambeneschan
2014-01-23 9:21 ` Georg Bauhaus
2014-01-22 22:45 ` adambeneschan
2014-01-23 5:29 ` J-P. Rosen
2014-01-23 7:00 ` Natasha Kerensikova
2014-01-23 9:42 ` Georg Bauhaus
2014-01-23 7:02 ` Natasha Kerensikova
2014-01-23 16:41 ` adambeneschan
2014-01-24 9:58 ` Natasha Kerensikova
2014-01-24 22:30 ` Randy Brukardt
2014-01-24 22:47 ` Randy Brukardt [this message]
2014-01-26 14:19 ` Natasha Kerensikova
2014-01-28 23:43 ` Randy Brukardt
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox