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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,f822ae7b0f7433c1 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!news-in.ntli.net!newsrout1-win.ntli.net!ntli.net!news.highwinds-media.com!xara.net!gxn.net!194.159.246.34.MISMATCH!peer-uk.news.demon.net!kibo.news.demon.net!news.demon.co.uk!demon!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Translating an embedded C algorithm Date: Fri, 19 Jan 2007 20:41:23 +0000 Organization: Pushface Message-ID: References: <1168871816.263502.212100@11g2000cwr.googlegroups.com> NNTP-Posting-Host: pogner.demon.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: news.demon.co.uk 1169239284 21982 62.49.19.209 (19 Jan 2007 20:41:24 GMT) X-Complaints-To: abuse@demon.net NNTP-Posting-Date: Fri, 19 Jan 2007 20:41:24 +0000 (UTC) Cancel-Lock: sha1:nlZWXxiKoQZ+CkJCCzvBtFTUjfg= User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (darwin) Xref: g2news2.google.com comp.lang.ada:8350 Date: 2007-01-19T20:41:23+00:00 List-Id: "Steve" writes: > ------------------------------------------------------------------------ > -- MeasureTemperature > -- > -- Calculates the temperature in �C given the ADC count by lookup > -- table and linear interpolation of the diode circuit characteristic. > -- > -- Parameters: > -- AdcCount Raw ADC count. > -- > -- Returns: > -- Temperature in �C x 10. INVALID_TEMPERATURE if out of range. > ------------------------------------------------------------------------ > function MeasureTemperature( AdcCount : Adc_Reading ) return Kelvin_Tenths; If the comment says 'degrees C' the type returned should NOT be in Kelvin!!! And it seems extraordinarily contrary to the Ada view of life to return an integral value in tenths of a degree (never mind where the zero is). This should be a real number (I don't see any virtue in making the application deal in fixed-point, float might even be faster on modern hardware. OK, probably not on an 8-bit microcontroller!) And there's an inconsistency of style: AdcCount vs Adc_Reading. And shouldn't that be ADC_Reading? And what's with this weird non-LRM parenthesis style? --S