From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!reader02.eternal-september.org!aioe.org!x6YkKUCkj2qHLwbKnVEeag.user.46.165.242.91.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Trivial question: how to avoid confusing sec, min, hour and day in a program? Date: Mon, 6 Sep 2021 11:47:52 +0200 Organization: Aioe.org NNTP Server Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: gioia.aioe.org; logging-data="61002"; posting-host="x6YkKUCkj2qHLwbKnVEeag.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org"; User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 Content-Language: en-US X-Notice: Filtered by postfilter v. 0.9.2 Xref: reader02.eternal-september.org comp.lang.ada:62655 List-Id: On 2021-09-06 09:20, ldries46 wrote: > Op 5-9-2021 om 9:27 schreef Dmitry A. Kazakov: >> 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. >> >>> It is somewhere in my program natural/human to think in seconds >>> whereas  minutes or hours feels more natural at other places (so the >>> numerics is "human"). Example to illustrate: heart rate is "natural" >>> to give in number per minute (not in number per second, hour or day). >>> Time on work is normally given by hours (not seconds) etc.. >> >> The user interface is responsible to convert anything to Duration and >> back. >> > I agree with Dimitry but I think the problem  is far bigger and not only > in Ada but in every computer language. You cannot use packages written > by others if you do not know the dimensions they use. For instance in > mechanical engineering in Europe there is a general use of cm while in > other countries they use inches and in aircraft engineering they use in > Europe mostly mm. Why do you need that? If written in Ada, the value is of some separate numeric type you could not mix with other types. > In general the use of dimensioning system ( f.i. cgs -cm gram second) is > different for different countries and application area's. Some factors > used within calculations are even dependant in the dimensioning system. > It would be a good idea if a package was developed that can solve all > these problems for instance by doing the calculations in one of the > possible dimensioning systems automagically presenting the results in > the dimension you choose. If calculations are involved, they are performed in SI, because otherwise you need factors in all formulae. And SI means no mm, but m, no km/h, but m/s etc. > Such a system must exist of a record for every value, that exist of at > least  real values for the standard dimensioning system and the value in > the dimensioning system you want, the factor between the two systems and > the string containing the dimension, perhaps even more. > There should be functions for "+", "-", "*", "/" and sqrt. http://www.dmitry-kazakov.de/ada/units.htm -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de