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!.POSTED!not-for-mail From: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Re: Ok to assume type Duration is for more than one day? Date: Sun, 22 Jan 2017 13:28:36 +0100 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: <52d00223-69b9-4a5c-a2e0-aaa906d9b200@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Sun, 22 Jan 2017 12:26:57 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="071644a2888e722161eca39ef3370f89"; logging-data="3058"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18F9vmOYO0tSyXkPX+nBt7ZwLVm1JPOpIM=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 In-Reply-To: <52d00223-69b9-4a5c-a2e0-aaa906d9b200@googlegroups.com> Cancel-Lock: sha1:QlVfITSOiyWCEh+mWlvTgwEk8XU= Xref: news.eternal-september.org comp.lang.ada:33119 Date: 2017-01-22T13:28:36+01:00 List-Id: On 01/22/2017 12:37 PM, reinkor wrote: > As I understand from my textbook, type Duration is guaranteed to cover the range -86_400 .. 86_400 (number of seconds for one day). Does this mean that I take a considerable risk if I assume "Duration" can represent more than one day? Representing that range with an accuracy of 20 ms takes about 22 bits, so most implementations will use at least 32 bits. The additional bits can be used for a greater range, a smaller accuracy, or both. ±86,400 with an accuracy of 20 µs takes about 32 bits, so a range of ±86,400 seems likely for some 32-bit compilers. > gives (gnat/debian and also Raspberry Pi (Raspbian)): > > Duration'Last : 292.5 > > (i.e. many years....). GNAT clearly uses more than 32 bits (a look at the GNAT documentation indicates 64 bits with an accuracy of 1 ns). If you're confident you'll never use another compiler, then go ahead (you might be surprised how many such systems I've seen ported to another compiler). If you want your code to be portable, then you'll limit yourself to ±86,400. -- Jeff Carter "I didn't squawk about the steak, dear. I merely said I didn't see that old horse that used to be tethered outside here." Never Give a Sucker an Even Break 103