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: a07f3367d7,fa37ee962bc4b00d X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!news.glorb.com!feeder.erje.net!newsfeed-fusi2.netcologne.de!195.14.215.230.MISMATCH!news.netcologne.de!newsfeed-hp2.netcologne.de!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Wed, 20 May 2009 13:11:05 +0200 From: Georg Bauhaus User-Agent: Thunderbird 2.0.0.21 (Macintosh/20090302) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Conversion from floating point to signed 16 bits References: <4a12ffa3$0$2853$ba620e4c@news.skynet.be> In-Reply-To: <4a12ffa3$0$2853$ba620e4c@news.skynet.be> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Message-ID: <4a13e54a$0$32672$9b4e6d93@newsspool2.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 20 May 2009 13:11:06 CEST NNTP-Posting-Host: 45a62e22.newsspool2.arcor-online.net X-Trace: DXC=n20WYi[j1k_mG86`U=_nC_A9EHlD;3YcR4Fo<]lROoRQ^YC2XCjHcbYDiF:K0ILb8Q;9OJDO8_SKVNSZ1n^B98iZGCL0PgRW Olivier Scalbert schrieb: > Hello, > > My problem: > I need to convert an "analogic" value which can vary from 0.0 to 1.0 > into a "discrete" value which is a signed 16 bits integer. > > My implementation: > ----------------------------- > with Ada.Text_IO; > > procedure convert is > type Analog_Value is digits 10 range 0.0 .. 1.0; > type Signed_16 is range -32768 .. 32767; > type Unsigned_16 is range 0 .. 65535; It might be an idea to use a different name for Unsigned_16 because this name is also declared in standard package Interfaces. Or use qualification. Avoids misunderstandings.