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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,f822ae7b0f7433c1 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII Newsgroups: comp.lang.ada Subject: Re: AW: Translating an embedded C algorithm References: <878xg2aqzr.fsf@ludovic-brenta.org> From: Markus E Leypold Organization: N/A Date: Wed, 17 Jan 2007 17:44:17 +0100 Message-ID: User-Agent: Some cool user agent (SCUG) Cancel-Lock: sha1:TTawyp3j6BlqJzB6VL+k1ZmPFwQ= MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit NNTP-Posting-Host: 88.72.233.113 X-Trace: news.arcor-ip.de 1169051994 88.72.233.113 (17 Jan 2007 17:39:54 +0200) X-Complaints-To: abuse@arcor-ip.de Path: g2news2.google.com!news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.arcor.de!newsfeed.arcor-ip.de!news.arcor-ip.de!not-for-mail Xref: g2news2.google.com comp.lang.ada:8235 Date: 2007-01-17T17:44:17+01:00 List-Id: Ludovic Brenta writes: > Grein, Christoph (Fa. ESG) writes: >> No, there are again some mistakes: >> >> ... >>> --| Temperature in �C x 10. INVALID_TEMPERATURE if out of range. >> >> Incorrect: There's no INVALID_TEMPERATURE >> >> ... >>> InterpolationDistance := (Adc_Count - MINIMUM_ADC_COUNT) mod (SPACING - 1); >> >> Wrong again: mod Spacing >> >> But: As others have pointed out, a mere translation of C code is not >> Ada. You would use constrained types rather than Integer and other >> Ada idioms (put it in a package, add context clauses, use different >> integer types for different abstractions etc...). > > Right, and there would be no need for a silly INVALID_TEMPERATURE. > What *is* an invalid temperature anyway? One that needs crutches? > One that is excused from military service? And why would you ever > return an invalid temperature to your caller? etc. etc. | >> --| Temperature in �C x 10. INVALID_TEMPERATURE if out of range. If the sensor is out of order or the temperature leaves the range where it functions properly? :-). Regards -- Markus