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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,b1850e397df49d95 X-Google-Attributes: gid103376,public From: dewar@merv.cs.nyu.edu (Robert Dewar) Subject: Re: How to convert an Fixed_Point to to an Integer ? Date: 1996/12/25 Message-ID: #1/1 X-Deja-AN: 205904819 references: <01bbf058$cbdbf980$LocalHost@jerryware> <1996Dec23.072835.1@eisner> <01bbf179$0c4361e0$9b2d5c8b@jerryware> <01bbf24c$a8db4800$b72d5c8b@jerryware> organization: New York University newsgroups: comp.lang.ada Date: 1996-12-25T00:00:00+00:00 List-Id: iJerry said (wrt my solution of the epoch problem) "Yep, but I will await your reaction to Norman's comment first." Well your original solution was even more GNAT specific :-) The question is whether or not there are Ada 95 compilers (other than GNAT) that actually have a very limited range for Duration. It is quite possible that the answer is yes. In GNAT, 64-bit integer and 64-bit fixed-point arithmetic are always available on all targets, and Duration is a 64-bit fixed-point value. However, surprisingly, many Ada 83 technologies did not support integer values longer than 32 bits, so it would not surprise me if there are Ada 95 compilers around with 32-bit Duration (it is *just* possible to squeeze Duration in to 32 bits -- by design). I feel that taking advantage of this permission to provide a very restricted duration is unfortunate, but if you want to write completely Rm-portable code, then Norman is right, you should take this into account. The way to do this is to write a loop using Time_Of that goes forward one year at a time, accumulating seconds, starting with 1970, till you get to the year you want. Of course you could make this a memo function so that once it knew the number of seconds to the start of a given year, it would not compute it again. Note that if you use Integer as the result, you are also creating another source of potential portability problems. In GNAT, Integer is always at least 32 bits, at least on all currnt targets (it is actually the sam as the C int in length), but there may be Ada 95 compilers with smaller Integer types, so really you should define an appropraite range type as the result of this seconds-from-the-Unix-epoch call. Better would be to make your program independent of this curious Unix-based notion of the Epoch all together. This being said, using the C routine is quite appropriate in this case anyway, since obviously you are doing something rather Unix specific ....