comp.lang.ada
 help / color / mirror / Atom feed
From: adambeneschan@gmail.com
Subject: Re: How to round to the nearest fixed-point value?
Date: Thu, 23 Jan 2014 08:41:41 -0800 (PST)
Date: 2014-01-23T08:41:41-08:00	[thread overview]
Message-ID: <221ced1a-3a8d-4600-8e8e-b83e49652821@googlegroups.com> (raw)
In-Reply-To: <slrnle1fkt.1lme.lithiumcat@sigil.instinctive.eu>

On Wednesday, January 22, 2014 11:02:59 PM UTC-8, Natasha Kerensikova wrote:
> 
> > I'm pretty sure this is a compiler bug.  Since Low'Small is a multiple of High'Small, you can work around it by changing the definition of Convert to
> 
> >     return Low (Value + Low'Small / 2);
> 
> > (Low'Small is a universal real and therefore Low'Small/2 will be interpreted as a value of type High.  The type conversion to Low will truncate.)
> 
> 
> 
> I have been considering that, however it seems type conversion truncates
> towards zero, so the expression above is only correct for positive
> Values, while Low'Small/2 should be subtracted when Value is negative.
> 
> Or am I missing something?

My fault, I forgot about negative values.

                              -- Adam

  reply	other threads:[~2014-01-23 16:41 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 [this message]
2014-01-24  9:58 ` Natasha Kerensikova
2014-01-24 22:30   ` Randy Brukardt
2014-01-24 22:47     ` Randy Brukardt
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