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,f9957894e0bdf128 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!a12g2000pro.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: How to put 200 into an integer sub-type of 16 bits (code included) Date: Wed, 14 Jan 2009 12:41:18 -0800 (PST) Organization: http://groups.google.com Message-ID: <87816592-c947-4bbc-92ed-7473646a105e@a12g2000pro.googlegroups.com> References: <407ae64d-3cb3-4310-b59e-f1bbae9910a5@t39g2000prh.googlegroups.com> <71gqm49eatq868htrvd7eghm3m8su8kcbl@4ax.com> <3d3719f4-355c-4094-9902-495d612d46fe@n33g2000pri.googlegroups.com> <139961e9-bae6-4e60-8ff7-4f4779b27481@z6g2000pre.googlegroups.com> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1231965679 10541 127.0.0.1 (14 Jan 2009 20:41:19 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 14 Jan 2009 20:41:19 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: a12g2000pro.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.7.12-1.3.1,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:3292 Date: 2009-01-14T12:41:18-08:00 List-Id: On Jan 14, 12:13 pm, ChristopherL wrote: > I want to copy bits from an Ada float to a user defined short integer > maintaining the same > bit representation. OK, why? Depending on your hardware, a float is likely 32 or 64 bits, maybe 80. I've occasionally seen different sizes, but I don't recall ever seeing a 16-bit float, and definitely not an 8-bit float. Your short integer is an 8-bit integer. (If you want it to be a 16- bit integer, why would you give it a range of -128 .. 127, rather than -32768 .. 32767?) OK, assuming that want to copy bits from an "Ada float", which is actually a hardware float supported by your processor and has nothing to do with your programming language, to a short integer: You want to copy bits from a 32-bit float, perhaps, to an 8-bit integer. Which bits do you want to copy? The ones containing the exponent or part of it, or the low-order mantissa bits, or some other sequence of bits? Why don't you want to copy the other 24 bits? If you have no idea what I'm talking about, then you have certainly stated your problem incorrectly, and you need to rethink your problem and restate what you want to accomplish, at a high level, without referring to "bits". Actually, I already suspect that you don't want what you said you want (copying bits from a float), because if you really did want to copy bits from a floating-point representation, you wouldn't be concerned with rounding. -- Adam