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=unavailable autolearn_force=no version=3.4.4 Path: Xl.tags.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail NNTP-Posting-Date: Wed, 01 Oct 2014 08:17:54 -0500 From: Dennis Lee Bieber Newsgroups: comp.lang.ada Subject: Re: casting types Date: Wed, 01 Oct 2014 09:18:03 -0400 Organization: IISS Elusive Unicorn Message-ID: References: X-Newsreader: Forte Agent 6.00/32.1186 X-No-Archive: YES MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 108.79.220.130 X-Trace: sv3-0Y8+iIgIRhmGHwjUQ/bxOXKwOw/a/gxb9MeCyBRAv97eFmv8M8MenD6lyuY2B5E+JtUp2YY2Sd6RlY3!xeNzYlZ4ozrTN7+BLARYBoT0fWUDYLht9vKlNsubkcseGH+mlrLAjmFZLWeZVkbbAqkjFLN936Pe!NPai6sqfQb9zKWjHrqJR3y07v4Gv X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 2857 Xref: number.nntp.giganews.com comp.lang.ada:189273 Date: 2014-10-01T09:18:03-04:00 List-Id: On Tue, 30 Sep 2014 19:56:59 -0700 (PDT), Stribor40 declaimed the following: >ok so i tried truncation attribute and that works just great. Now I want to output this float point to the screen and this is the way i did it....myFunction is myFunction that returns float.... > >Put(Item=>myFunction,Exp=>0,Aft=>5); > >which gives me for example something like this... 0.42997 where without using this function i would get for example 3.23684E-01..... > Unless your function is really corrupting things, I expect the second to be 4.2997E-01 Floating point values (in any programming language) do not behave as "real numbers"... One) they are stored as binary floats, not decimal, so don't expect exact conversions in/out. Two) they are stored as an exponent, and a mantissa of the significant binary value -- no 0.00001, rather 1.0E-5 [if I counted correctly]. So, yes, you do have to control the formatting for display purposes. Your original post isn't too clear either... >I have problem understanding this explicit conversion of types.... > > var1: FLOAT; > > tmp := Float(x) / 20.0 + Float(y)/ 30.0 + Float(z)/40.0; Do these serve any purpose? Neither tmp, x, y, z are declared or initialized > return var1 - truncated type of var1 > >Example if var1 = 123.456 then > return 123.456 - 123 > >which is 0.123 > 123.456 - 123 should leave 0.456 >How would I cast var1 to become 123 but still be able to subtract it from var1 and keep float type? >Is there any other way to do this? -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/