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,a34155c47adc46f2 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!feeder.news-service.com!85.214.198.2.MISMATCH!eternal-september.org!.POSTED!not-for-mail From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: Looking For Simple Routine To Put Integer Into Float Date: Tue, 25 May 2010 00:53:41 +0200 Organization: A noiseless patient Spider Message-ID: <87eih0ap3e.fsf@ludovic-brenta.org> References: <570f8963-82ba-42b9-981f-0f92e59161b3@a2g2000prd.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Date: Mon, 24 May 2010 22:53:41 +0000 (UTC) Injection-Info: mx03.eternal-september.org; posting-host="upFsF0xhD85Qtx/JQ+ZAvg"; logging-data="22885"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/mKsySw0GNX7xbE863I88s" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:PBDxOvwH+XZ/mO5zCCDKQmg1nTI= sha1:V7NYi2dfabtHADfP8jDYFBMcHi0= Xref: g2news2.google.com comp.lang.ada:11944 Date: 2010-05-25T00:53:41+02:00 List-Id: ChristopherL writes: > Can you modify the below code to convert an integer variable of 32 > bits to a variable of type float. Why does it matter that the integer variable is 32 bits? How many bits does the float type use? > type Unknown_integer_type is range -(2**16) ..(2**16) -1; -- 32 Bit > Integer This looks like a 17-bit integer type to me, not 32-bit. > An_Unknown_Integer: Unknown_integer_type; > An_Integer: Integer; > A_Float: Float; -- Hoping this float is usually 32 bits Then it cannot hold a 32-bit integer without losing some precision, since some of the float's 32 bits will be reserved for the exponent. But since the integer type is only 17-bit wide, that's OK; the mantissa of a 32-bit float is very probably wider than 17 bits. > An_Integer := 1234; > > An_Unknown_Integer := An_Integer; > > A_Float := Float (An_Unknown_Integer); That's a type conversion, it assigns the value 1234.0 to A_Float. Since you ask a question, I can only assume that that's now what you wanted. So what is it that you want, exactly? -- Ludovic Brenta.