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?
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 persecond, hour or day). Time on work is normally given by hours (not seconds) etc..
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.
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.
Op 5-9-2021 om 9:27 schreef Dmitry A. Kazakov:
On 2021-09-05 08:56, reinert wrote:I agree with Dimitry but I think the problem is far bigger and not only
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.
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.
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.
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.
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:I agree with Dimitry but I think the problem is far bigger and not
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.
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.
Sorry but It should perhaps be so but it is not. Programs made primarilyIn 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
Le 06/09/2021 à 15:06, ldries46 a écrit :
If calculations are involved, they are performed in SI, becauseSorry but It should perhaps be so but it is not. Programs made
otherwise you need factors in all formulae. And SI means no mm, but
m, no km/h, but m/s etc.
primarily for Aircraft engineering (f.i. CATIA 5/6) do use mm and
your velocity clock in your car shows km/h and it registers the
distance in km (in England and the USA mph and miles) In aircraft the
Speed is often still measured in Knots (Nautical miles per hour).
Maybe French aircraft will possibly show km/h. It is to hazardous to
change this
Do not confuse computations with input/output. I agree with Dmitry,
all computations should be performed in SI, with a (user selectable)
choice of units for input and display.
If calculations are involved, they are performed in SI, becauseSorry but It should perhaps be so but it is not. Programs made primarily
otherwise you need factors in all formulae. And SI means no mm, but m,
no km/h, but m/s etc.
for Aircraft engineering (f.i. CATIA 5/6) do use mm and your velocity
clock in your car shows km/h and it registers the distance in km (in
England and the USA mph and miles) In aircraft the Speed is often still measured in Knots (Nautical miles per hour). Maybe French aircraft will possibly show km/h. It is to hazardous to change this
100mm high. That is the reason that I ask for a package which solves
this problem for once and always and still gives the user the
possibility to use all kind of dimesions
http://www.dmitry-kazakov.de/ada/units.htm
It would be a good idea if a package was developed that can solve allThere's this package[-set] -- http://archive.adaic.com/tools/CKWG/Dimension/SI.html
these problems for instance by doing the calculations in one of the
possible dimensioning systems automagically presenting the results in
the dimension you choose.
I have already been thinking how but the problem are mostly in the stringsStrings are terrible, avoid thinking in strings; be about the data first and foremost.
I think that the potential of Ada of being independent of an operatingPossibly, the problem is addressed interestingly in VHDL via "physical units" where you can define a type and then use units with a conversion factor.
system can be extended that way to independent of the dimensioning system.
On 2021-09-05 08:56, reinert wrote:second, hour or day). Time on work is normally given by hours (not seconds) etc..
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
The user interface is responsible to convert anything to Duration and back.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
Ada seems to guarantee that Duration covers 24 hours (?). What you do when you need to represent for example 5 years?Ada /guarantees/ at least 24 hours, since subtype Day_Duration
Ada seems to guarantee that Duration covers 24 hours (?). What you do when you need to represent for example 5 years?
Put ("years:") ; Put (Duration'Last / 86400 / 365.25); New_Line;
years: 292.271023045
Ada seems to guarantee that Duration covers 24 hours (?). What you do
when you need to represent for example 5 years?
Ada seems to guarantee that Duration covers 24 hours (?). What you do when you need to represent for example 5 years?
The user interface is responsible to convert anything to Duration and back. >>
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 379 |
Nodes: | 16 (2 / 14) |
Uptime: | 43:58:04 |
Calls: | 8,141 |
Calls today: | 4 |
Files: | 13,085 |
Messages: | 5,857,952 |