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,9bb56e94a4c5bb5e X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!newshub.sdsu.edu!elnk-nf2-pas!elnk-pas-nf1!newsfeed.earthlink.net!cyclone.socal.rr.com!cyclone2.kc.rr.com!news2.kc.rr.com!twister.socal.rr.com.POSTED!53ab2750!not-for-mail Newsgroups: comp.lang.ada Subject: Re: How unchecked conversion works? References: From: Keith Thompson Message-ID: User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) Cancel-Lock: sha1:Mbb7Fb5j3gbqil/QK2o5+dVGljA= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Thu, 13 Jan 2005 22:28:04 GMT NNTP-Posting-Host: 66.91.240.168 X-Complaints-To: abuse@rr.com X-Trace: twister.socal.rr.com 1105655284 66.91.240.168 (Thu, 13 Jan 2005 14:28:04 PST) NNTP-Posting-Date: Thu, 13 Jan 2005 14:28:04 PST Organization: RoadRunner - West Xref: g2news1.google.com comp.lang.ada:7744 Date: 2005-01-13T22:28:04+00:00 List-Id: None writes: > HI! I'd like to know what the compiler do for represent a simple float > for example 34,4 delta 0.1 into an integer type for example range > 1..10 using an Unchecked_Conversion. Thanks! I'm not quite sure what you mean. For one thing, a type declared with "delta" is fixed-point, not floating-point. Doing an Unchecked_Conversion from floating-point to integer is unlikely to be useful. An Unchecked_Conversion from fixed-point to integer, on the other hand, might be; a fixed-point value is basically a scaled integer, and Unchecked_Conversion might make sense if you want to ignore the scaling. (Nevertheless, you should spend some time thinking about what problem you're trying to solve, and perhaps come up with a cleaner way to do it.) An Unchecked_Conversion call takes an operand of one type and pretends that it's a value of another type. This will typically be implemented in machine code simply by doing nothing. For example, if Conv is an instance of Unchecked_Conversion, and X and Y are of appropriate types, then this: X := Conv(Y); will probably just copy the value of Y into X, just as X := Y; would do if it were allowed. (Presumably it isn't allowed because X and Y are of incompatible types; otherwise you wouldn't need to use Unchecked_Conversion.) -- 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.