Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ada > #49420

Re: Trivial question: how to avoid confusing sec, min, hour and day in a program?

From Niklas Holsti <niklas.holsti@tidorum.invalid>
Newsgroups comp.lang.ada
Subject Re: Trivial question: how to avoid confusing sec, min, hour and day in a program?
Date 2021-09-05 15:42 +0300
Organization Tidorum Ltd
Message-ID <ipjsa9Fi441U1@mid.individual.net> (permalink)
References <c1e4f8bf-f3f0-4a14-b057-37f330461f9cn@googlegroups.com> <sh1rha$14d6$1@gioia.aioe.org>

Show all headers | View raw


On 2021-09-05 10:27, Dmitry A. Kazakov wrote:
> On 2021-09-05 08:56, reinert wrote:
>> Anybody with good ideas on how (in a simplest possible way) to avoid 
>> to confuse between representation of time as seconds, minutes, hours 
>> and days in an Ada program?
> 
> Just use the standard type Duration.


But note that:

- Duration is a fixed-point type, not floating point, so it has a fixed 
resolution, Duration'Small.

- The resolution and range of Duration are implementation-defined, and 
the standard does not guarantee much. RM 9.6(27) says:

"The implementation of the type Duration shall allow representation of 
time intervals (both positive and negative) up to at least 86400 seconds 
(one day); Duration'Small shall not be greater than twenty milliseconds."

(Aside: I wonder why this paragraph is not in RM A.1, "The Package 
Standard", where the Duration type is introduced.)

If you want your code to be portable, define your own type for "time in 
seconds", choosing the properties your application needs.

That said, I believe that GNAT versions typically provide a 64-bit 
Duration type that has enough precision and range for most applications 
dealing with times on human scales. But perhaps not on nuclear, 
geological or astrophysical scales.

Back to comp.lang.ada | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Trivial question: how to avoid confusing sec, min, hour and day in a program? reinert <reinkor@gmail.com> - 2021-09-04 23:56 -0700
  Re: Trivial question: how to avoid confusing sec, min, hour and day in a program? "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2021-09-05 09:27 +0200
    Re: Trivial question: how to avoid confusing sec, min, hour and day in a program? Niklas Holsti <niklas.holsti@tidorum.invalid> - 2021-09-05 15:42 +0300
    Re: Trivial question: how to avoid confusing sec, min, hour and day in a program? ldries46 <bertus.dries@planet.nl> - 2021-09-06 09:20 +0200
      Re: Trivial question: how to avoid confusing sec, min, hour and day in a program? "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2021-09-06 11:47 +0200
        Re: Trivial question: how to avoid confusing sec, min, hour and day in a program? ldries46 <bertus.dries@planet.nl> - 2021-09-06 15:06 +0200
          Re: Trivial question: how to avoid confusing sec, min, hour and day in a program? "J-P. Rosen" <rosen@adalog.fr> - 2021-09-06 15:43 +0200
            Re: Trivial question: how to avoid confusing sec, min, hour and day in a program? ldries46 <bertus.dries@planet.nl> - 2021-09-06 16:13 +0200
              Re: Trivial question: how to avoid confusing sec, min, hour and day in a program? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2021-09-06 11:10 -0400
        Re: Trivial question: how to avoid confusing sec, min, hour and day in a program? AdaMagica <christ-usch.grein@t-online.de> - 2021-09-06 08:55 -0700
      Re: Trivial question: how to avoid confusing sec, min, hour and day in a program? Shark8 <onewingedshark@gmail.com> - 2021-09-08 15:00 -0700
    Re: Trivial question: how to avoid confusing sec, min, hour and day in a program? reinert <reinkor@gmail.com> - 2021-10-23 23:52 -0700
      Re: Trivial question: how to avoid confusing sec, min, hour and day in a program? "J-P. Rosen" <rosen@adalog.fr> - 2021-10-24 09:24 +0200
        Re: Trivial question: how to avoid confusing sec, min, hour and day in a program? "Jeffrey R.Carter" <spam.jrcarter.not@spam.acm.org.not> - 2021-10-24 12:39 +0200
      Re: Trivial question: how to avoid confusing sec, min, hour and day in a program? "G.B." <bauhaus@notmyhomepage.invalid> - 2021-10-24 12:08 +0200
      Re: Trivial question: how to avoid confusing sec, min, hour and day in a program? Simon Wright <simon@pushface.org> - 2021-10-24 11:48 +0100
      Re: Trivial question: how to avoid confusing sec, min, hour and day in a program? Björn Lundin <b.f.lundin@gmail.com> - 2021-10-24 14:09 +0200

csiph-web