comp.lang.ada
 help / color / mirror / Atom feed
From: reinkor <reinkor@gmail.com>
Subject: Ok to assume type Duration is for more than one day?
Date: Sun, 22 Jan 2017 03:37:57 -0800 (PST)
Date: 2017-01-22T03:37:57-08:00	[thread overview]
Message-ID: <52d00223-69b9-4a5c-a2e0-aaa906d9b200@googlegroups.com> (raw)

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?

The following program:

----------------------------------------------------------------
with Ada.Numerics.Generic_Elementary_Functions,Text_IO;
use Text_IO;
with Ada.Calendar; use Ada.Calendar;

procedure d1 is

   package Flt_Io is new Text_IO.Float_Io   (Float);
   package Int_Io is new Text_IO.Integer_Io (Integer);
   package E_F is new Ada.Numerics.Generic_Elementary_Functions (Float);
   use E_F,Flt_Io,Int_Io;

   d : Duration := Duration(3600*24*10);

begin

   Put(" Duration'Last : ");
   Put(Float(Duration'Last)/(3600.0*24.0*365.0),20,1,0);

end d1;
--------------------------------------------------------------

gives (gnat/debian and also Raspberry Pi (Raspbian)):

Duration'Last :                  292.5

(i.e. many years....).

reinert

             reply	other threads:[~2017-01-22 11:37 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-22 11:37 reinkor [this message]
2017-01-22 12:28 ` Ok to assume type Duration is for more than one day? Jeffrey R. Carter
2017-01-23 20:47   ` Randy Brukardt
2017-01-22 16:39 ` AdaMagica
2017-01-23  8:35 ` G.B.
2017-01-23  8:43   ` G.B.
2017-01-23 13:32   ` Björn Lundin
2017-01-23 13:53     ` G.B.
2017-01-23 14:32       ` Björn Lundin
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox