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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.albasani.net!newsfeed.xs3.de!io.xs3.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Arrays in Ada 2012 Date: Wed, 7 Jun 2017 19:51:38 -0500 Organization: JSA Research & Innovation Message-ID: References: <35c6ac5a-3295-4fa4-8545-ca76c113dde4@googlegroups.com> NNTP-Posting-Host: rrsoftware.com X-Trace: franka.jacob-sparre.dk 1496883099 8573 24.196.82.226 (8 Jun 2017 00:51:39 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Thu, 8 Jun 2017 00:51:39 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Xref: news.eternal-september.org comp.lang.ada:46916 Date: 2017-06-07T19:51:38-05:00 List-Id: "Dmitry A. Kazakov" 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.