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,f93adbf272b6f27 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news.glorb.com!wns13feed!worldnet.att.net!24.30.200.11!news-east.rr.com!news-feed-01.rdc-kc.rr.com!news.rr.com!cyclone2.kc.rr.com!news2.kc.rr.com!tornado.socal.rr.com.POSTED!53ab2750!not-for-mail Newsgroups: comp.lang.ada Subject: Re: how to safely convert from 32 to 16 bits? References: <6acda821.0506040923.1790561c@posting.google.com> From: Keith Thompson Message-ID: User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) Cancel-Lock: sha1:Np+ZlOU3Zxi+D2mKdbV8fDe+JsM= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Sun, 05 Jun 2005 05:03:43 GMT NNTP-Posting-Host: 66.75.136.120 X-Complaints-To: abuse@rr.com X-Trace: tornado.socal.rr.com 1117947823 66.75.136.120 (Sat, 04 Jun 2005 22:03:43 PDT) NNTP-Posting-Date: Sat, 04 Jun 2005 22:03:43 PDT Organization: Road Runner High Speed Online http://www.rr.com Xref: g2news1.google.com comp.lang.ada:11244 Date: 2005-06-05T05:03:43+00:00 List-Id: "David C. Hoos, Sr." writes: > "Sebastian" writes: >> Ho do I convert a larger variable like Integer to an smaller type >> without loosing any data? >> What I would like to do is: >> I have a variable of Integer_32 size, I also know that the value is >> always between -180 and 180. I would like to assign that value to a 16 >> bits Real type. >> How can that be done without loosing any data? > > What compiler and hardware are you using that has a 16-bit Real type? It could be a fixed-point type. If so, knowing that it's 16 bits doesn't necessarily tell us that it can hold all values from -180 to 180. To the original poster: How exactly is Real declared? If the target type can hold all the expected values, just do a conversion. If it can't, there's nothing you can do to make all the values fit (unless you change the type). -- Keith Thompson (The_Other_Keith) kst-u@mib.org San Diego Supercomputer Center <*> We must do something. This is something. Therefore, we must do this.