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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,55d12b9409d3b4cd X-Google-Attributes: gid103376,public Path: controlnews3.google.com!news1.google.com!news.glorb.com!cyclone1.gnilink.net!gnilink.net!bigfeed2.bellsouth.net!news.bellsouth.net!elnk-atl-nf1!newsfeed.earthlink.net!stamper.news.atl.earthlink.net!stamper.news.pas.earthlink.net!newsread1.news.pas.earthlink.net.POSTED!a6202946!not-for-mail From: Jeffrey Carter Organization: jrcarter commercial-at acm [period | full stop] org User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Newbie Question: Casting Issue References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Date: Tue, 04 May 2004 17:40:03 GMT NNTP-Posting-Host: 63.184.17.67 X-Complaints-To: abuse@earthlink.net X-Trace: newsread1.news.pas.earthlink.net 1083692403 63.184.17.67 (Tue, 04 May 2004 10:40:03 PDT) NNTP-Posting-Date: Tue, 04 May 2004 10:40:03 PDT Xref: controlnews3.google.com comp.lang.ada:246 Date: 2004-05-04T17:40:03+00:00 List-Id: Davide wrote: > I need your help, please, to solve a casting issue. There are no casting issues in Ada. It appears that you are talking about type conversions. > I cannot use Ada exceptions and I must ensure that the assignment will not > throw a type constraint error at run-time. In Ada, exceptions are raised. > FLOAT_VAR >= FLOAT_POINT_TYPE(FIX_POINT_TYPE'FIRST) > and > FLOAT_VAR <= FLOAT_POINT_TYPE(FIX_POINT_TYPE'LAST) Float_Var in Float_Point_Type (Fix_Point_Type'First) .. Float_Point_Type (Fix_Point_Type'Last) Perhaps better would be subtype Float_Fix is Float_Point_Type range Float_Point_Type (Fix_Point_Type'First) .. Float_Point_Type (Fix_Point_Type'Last); ... Float_Var in Float_Fix > FIX_VAR := FLOAT_VAR. Which will not compile, for more than one reason. Your compiler will explain this to you. Accuracy questions depend on whether your compiler implements Annex G. -- Jeff Carter "When danger reared its ugly head, he bravely turned his tail and fled." Monty Python and the Holy Grail 60