comp.lang.ada
 help / color / mirror / Atom feed
* Ok to assume type Duration is for more than one day?
@ 2017-01-22 11:37 reinkor
  2017-01-22 12:28 ` Jeffrey R. Carter
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: reinkor @ 2017-01-22 11:37 UTC (permalink / 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

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-01-23 20:47 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-22 11:37 Ok to assume type Duration is for more than one day? reinkor
2017-01-22 12:28 ` 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

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