comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Arrays in Ada 2012
Date: Wed, 7 Jun 2017 19:51:38 -0500
Date: 2017-06-07T19:51:38-05:00	[thread overview]
Message-ID: <oha72q$8bt$1@franka.jacob-sparre.dk> (raw)
In-Reply-To: oh88l2$gsf$1@gioia.aioe.org

"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message 
news:oh88l2$gsf$1@gioia.aioe.org...
> On 06/06/2017 22:56, Randy Brukardt wrote:
>
>>         Current := Current + Long_Long_Integer'Size/Storage_Unit;
>
> A bit OT question.
>
> I always use rounding in the corresponding cases
>
>    (Long_Long_Integer'Size + Storage_Unit - 1) / Storage_Unit;
>
> Is this an overkill from the point of view the permissions RM gives to 
> array implementation?

The definition of 'Size is stupid, so you need rounding like that to be 
portable. It's probably not necessary for base types, but if you had
    (Natural'Size / Storage_Unit)
you would get the wrong answer (Ada requires Natural'Size to be one less 
than Integer'Size, so it usually is 15 or 31 or 63).

Probably a better solution is to use 'Object_Size for such expressions, but 
that is only portable to Ada 202x compilers (for which none exist yet for 
obvious reasons). Object_Size usually will be a multiple of the storage 
unit; that's the Implementation Advice for it, but of course some 
implementation could ignore that in some circumstance.

                              Randy.


  parent reply	other threads:[~2017-06-08  0:51 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-06 11:47 Arrays in Ada 2012 Anatoly Chernyshev
2017-06-06 12:17 ` Dmitry A. Kazakov
2017-06-06 13:17   ` Simon Wright
2017-06-06 13:57     ` Dmitry A. Kazakov
2017-06-06 21:59       ` Simon Wright
2017-06-06 13:19 ` AdaMagica
2017-06-06 20:56   ` Randy Brukardt
2017-06-07  7:06     ` Dmitry A. Kazakov
2017-06-07 11:47       ` Anatoly Chernyshev
2017-06-07 12:15         ` Dmitry A. Kazakov
2017-06-08  0:55         ` Randy Brukardt
2017-06-08  0:51       ` Randy Brukardt [this message]
2017-06-08  7:07         ` Dmitry A. Kazakov
2017-06-09  3:23           ` Randy Brukardt
2017-06-18  2:14 ` Arrays in Ada 2020 Ivan Levashev
2017-06-18  3:00   ` Nasser M. Abbasi
2017-06-18 12:06     ` Robert Eachus
2017-06-18 20:15       ` Simon Wright
2017-06-20 13:33         ` Robert Eachus
2017-06-19  6:36       ` Ivan Levashev
2017-06-19 12:06         ` AdaMagica
2017-06-23  1:17           ` Randy Brukardt
2017-06-18 20:15     ` 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