From: Andreas.Schmidl@googlemail.com
Subject: Modify value - type duration
Date: Wed, 5 Nov 2008 13:50:59 -0800 (PST)
Date: 2008-11-05T13:50:59-08:00 [thread overview]
Message-ID: <7ef68540-6df1-4e47-b425-ab08c03f2db9@p31g2000prf.googlegroups.com> (raw)
Hello!
I started programming in Ada for about a month. Because of that my
knowledge isn't really good, but will be better every day ;-)
I have a problem to modify a fixed point value (type duration).
I want to cut all before the point. Example:
---------------------------------------------------
var1 : duration := 12.345;
var2 : duration;
var2 := cutIt(num => var1);
---------------------------------------------------
var2 is now 0.345. To implement the function "cutIt" I tested an idea.
I converte var1 to an integer:
---------------------------------------------------
function cutIt(var : duration) return duration is
tempvar : integer;
begin
tempvar := integer(var);
return (var - duration(tempvar));
end cutIt;
--------------------------------------------------
But this isn't a solution. Converting to integer with integer(...)
round the value.
Example:
12.345 ---> 12
12.854 ---> 13
Is there any other more elegant and functional solution in Ada?
Thanks for your help!
Best regards!
Andreas
next reply other threads:[~2008-11-05 21:50 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-05 21:50 Andreas.Schmidl [this message]
2008-11-05 22:47 ` Modify value - type duration Jeffrey R. Carter
2008-11-06 1:03 ` Adam Beneschan
2008-11-06 1:57 ` Jeffrey R. Carter
2008-11-06 21:14 ` Keith Thompson
2008-11-07 1:33 ` Randy Brukardt
2008-11-07 11:10 ` Ludovic Brenta
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox