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=0.7 required=5.0 tests=BAYES_00,MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,f8311a3a7edd715 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2000-12-12 15:20:07 PST Path: supernews.google.com!sn-xit-02!supernews.com!isdnet!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!nntp2.deja.com!nnrp1.deja.com!not-for-mail From: Ted Dennison Newsgroups: comp.lang.ada Subject: Re: Using "delay until" in real-time Date: Tue, 12 Dec 2000 23:09:46 GMT Organization: Deja.com Message-ID: <916b7k$9n7$1@nnrp1.deja.com> References: <915jl7$jt5$1@nnrp1.deja.com> NNTP-Posting-Host: 204.48.27.130 X-Article-Creation-Date: Tue Dec 12 23:09:46 2000 GMT X-Http-User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; m18) Gecko/20001207 X-Http-Proxy: 1.0 x62.deja.com:80 (Squid/1.1.22) for client 204.48.27.130 X-MyDeja-Info: XMYDJUIDtedennison Xref: supernews.google.com comp.lang.ada:3025 Date: 2000-12-12T23:09:46+00:00 List-Id: In article <915jl7$jt5$1@nnrp1.deja.com>, Ted Dennison wrote: > o Figure out what the denominator is (60 in this case), and redo > the calculation every time that number of runs have happened. > > For instance, in the above code, I'd add something like: > Runs := Runs + 1; > if Runs >= Natural(Iteration_Hz) then > -- Adjust for drift due to rounding errors. > Runs := 0; > Run_Time := Run_Time + Ada.Real_Time.To_Time_Span (1.0); > Next_Time := Run_Time; > else > Next_Time := Next_Time + Iteration; > end if; Arg! Slight problem with this. Since 1/60th rounds UP, that means the first time I enter the else part, the next delay until delays *2* ticks instead of one. Then when I do the adjustment, it asks to delay until a time that has already occurred, which misses a tick (or double-ticks, I'm not sure which). Ug. Is there a way to specify that a floating-point calculation must round down? The only other out I see would be to multiply by some largish power of 10 then do a 'floor and divide that power of 10 back out. Yuck. -- T.E.D. http://www.telepath.com/~dennison/Ted/TED.html Sent via Deja.com http://www.deja.com/