Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #43635
| Newsgroups | comp.lang.forth |
|---|---|
| Date | 2015-11-22 06:33 -0800 |
| References | <n2qss7$2mo$1@dont-email.me> |
| Message-ID | <fc2fbd3f-00fa-4e6b-ae01-b57080faebae@googlegroups.com> (permalink) |
| Subject | Re: RfD: D>F and S>F first draft |
| From | krishna.myneni@ccreweb.org |
On Saturday, November 21, 2015 at 4:59:34 PM UTC-6, C G Montgomery wrote: > Author: > > Charles G. Montgomery <cgm@physics.utoledo.edu> > > Problem: > > The current Forth Standard specification for D>F states that an ambiguous > condition exists if the double number D cannot be precisely represented as > a floating-point value. > Similarly, the specification for S>F calls for an ambiguous condition if > the single number N can not be precisely represented as a floating-point "can not" --> cannot > value. > > The purpose of this proposal is to eliminate these ambiguous conditions by > instead specifying that if no floating-point value is precisely equivalent > to the provided integer the word provides the floating-point value which > is closest to the integer. > is closest to the integer, within the floating point representation used by the system. An ambiguous condition may still exist if the maximum double length integer exceeds the maximum representable floating point number. > This is the behavior provided by some Standard Forth systems, and is often > what is most useful for the programmer. > > Preliminary Remarks: > > While Forth is largely untyped, it recognizes the distinction between > integer and floating-point values. Section 12.3.1.2 says "The internal > representation of a floating-point number, including the format and > prescision of the significand and the format and range of the exponent, is > implementation defined." > This seems to presume that the representation of > a floating-point value is of the form > (significand) * (base)^(exponent) > where (significand), (base), and (exponent) are integers. Since Section > 12.3.2 refers to the "least significant bit" in defining "round to > nearest", (base) is presumably 2. > I am not aware of any Forth which is not consistent with these > presumptions. The above discussion seems irrelevant to the problem at hand. > So the "representable values" of floating-point numbers is a countable > subset of the uncountable real numbers. > > Integers in Forth may be signed or unsigned. Floating point values are > almost invariably signed, so (significand) includes a sign. D in D>F is > presumably signed. > > Proposal: > > In 2.6.1.1130 D>F (d -- )(F: -- r) replace > "r is the floating point equivalent of d. An ambiguous condition exists > if d can not be precisely represented as a floating-point value" > with > "r is the floating-point value which is nearest to d in the sense of > 'round to nearest' as given in 12.3.2." > An ambiguous condition may still exist, per my earlier comment, if the exponent part of the number r cannot span the full range of double length integers. As far as I know, this does not pose a problem for any existing systems. > In 12.6.2.2175 S>F (n -- )(F: -- r) replace > "r is the floating-point equivalent of the single-cell value n. An > ambiguous condition exists if n can not be precisely represented as a > floating-point value." > with > "r is the floating-point value which is nearest to n in the sense of > 'round to nearest' as given in 12.3.2." > > Remove the documentation requirements in section 12.4.1.2 for the no > longer existing ambiguous conditions from D>F and S>F. > > Further Remarks: > > D>F is in the FLOATING word set; S>F is in the FLOATING EXT word set. > > The reverse operations, F>D and F>S, are unchanged. For each, the > Standard includes a note pointing out that rounding a floating-point value > before using them may be desirable. > > No change is needed for the possibly relevant words >FLOAT and REPRESENT. > > It remains easy to determine whether the conversion from float to integer Don't you mean, integer to float? > is precise, by comparing the initial integer value with the result of D>F Change "precise" to exact. > F>D or S>F F>S. > > Implementation and Testing: > > For any system which provides the FLOATING and FLOATING EXT word sets and > does not already comply with this proposal it should not be difficult to > implement. > Whether floating-point support is in hardware or software, if FROUND can > be provided > it should be no harder to provide the proposed behavior of D>F and S>F. > > The intentional flexibility of the Standard in specifying floating point > internal representations makes it difficult to provide tests which have > universal applicability to all Standard systems. > The above statement, I think, is wrong. As long as the range of double length numbers and the intrinsic floating point numbers is well-defined by the Forth system, tests for correct behavior should be possible. KM
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
RfD: D>F and S>F first draft C G Montgomery <cgm@physics.utoledo.edu> - 2015-11-21 17:59 -0500
Re: D>F and S>F first draft "HAA" <someone@microsoft.com> - 2015-11-22 18:25 +1100
Re: D>F and S>F first draft krishna.myneni@ccreweb.org - 2015-11-22 06:20 -0800
Re: D>F and S>F first draft "HAA" <someone@microsoft.com> - 2015-11-23 10:58 +1100
Re: D>F and S>F first draft Bernd Paysan <bernd.paysan@gmx.de> - 2015-11-23 02:57 +0100
Re: D>F and S>F first draft "HAA" <someone@microsoft.com> - 2015-11-24 13:16 +1100
Re: D>F and S>F first draft Paul Rubin <no.email@nospam.invalid> - 2015-11-23 18:49 -0800
Re: D>F and S>F first draft "HAA" <someone@microsoft.com> - 2015-11-25 11:51 +1100
Re: D>F and S>F first draft Paul Rubin <no.email@nospam.invalid> - 2015-11-24 17:26 -0800
Re: D>F and S>F first draft Bernd Paysan <bernd.paysan@gmx.de> - 2015-11-25 02:43 +0100
Re: D>F and S>F first draft "HAA" <someone@microsoft.com> - 2015-11-26 12:16 +1100
Re: D>F and S>F first draft Paul Rubin <no.email@nospam.invalid> - 2015-11-25 17:47 -0800
Re: D>F and S>F first draft "HAA" <someone@microsoft.com> - 2015-11-26 15:47 +1100
Re: D>F and S>F first draft Paul Rubin <no.email@nospam.invalid> - 2015-11-25 23:07 -0800
Re: D>F and S>F first draft anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-11-26 07:27 +0000
Re: D>F and S>F first draft anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-11-26 09:19 +0000
Re: D>F and S>F first draft "HAA" <someone@microsoft.com> - 2015-11-28 04:26 +1100
Re: D>F and S>F first draft anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-11-28 11:31 +0000
Re: D>F and S>F first draft "HAA" <someone@microsoft.com> - 2015-11-29 20:23 +1100
Re: D>F and S>F first draft Bernd Paysan <bernd.paysan@gmx.de> - 2015-11-29 20:39 +0100
Re: D>F and S>F first draft "HAA" <someone@microsoft.com> - 2015-12-05 17:48 +1100
Re: D>F and S>F first draft Julian Fondren <julian.fondren@gmail.com> - 2015-12-04 23:58 -0800
Re: D>F and S>F first draft mhx@iae.nl - 2015-12-05 02:19 -0800
Re: D>F and S>F first draft anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-12-05 11:25 +0000
Re: D>F and S>F first draft Albert van der Horst <albert@spenarnc.xs4all.nl> - 2015-12-05 13:11 +0000
Re: D>F and S>F first draft mhx@iae.nl - 2015-12-05 05:27 -0800
Re: D>F and S>F first draft anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-12-05 15:33 +0000
Re: D>F and S>F first draft mhx@iae.nl - 2015-12-07 10:10 -0800
Re: D>F and S>F first draft anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-12-09 16:58 +0000
Re: D>F and S>F first draft krishna.myneni@ccreweb.org - 2015-12-06 10:23 -0800
Re: D>F and S>F first draft Bernd Paysan <bernd.paysan@gmx.de> - 2015-12-06 21:37 +0100
Re: D>F and S>F first draft Bernd Paysan <bernd.paysan@gmx.de> - 2015-12-05 19:08 +0100
Re: D>F and S>F first draft anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-11-30 08:33 +0000
Re: D>F and S>F first draft "Elizabeth D. Rather" <erather@forth.com> - 2015-11-25 21:43 -1000
Re: D>F and S>F first draft "HAA" <someone@microsoft.com> - 2015-11-28 19:28 +1100
Re: D>F and S>F first draft Albert van der Horst <albert@spenarnc.xs4all.nl> - 2015-11-26 11:37 +0000
Re: D>F and S>F first draft anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-11-22 15:10 +0000
Re: D>F and S>F first draft Bernd Paysan <bernd.paysan@gmx.de> - 2015-11-22 20:48 +0100
Re: D>F and S>F first draft "Elizabeth D. Rather" <erather@forth.com> - 2015-11-22 13:42 -1000
Re: D>F and S>F first draft anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-11-23 11:50 +0000
Re: D>F and S>F first draft "Elizabeth D. Rather" <erather@forth.com> - 2015-11-23 12:46 -1000
Forth libraries Lars Brinkhoff <lars.spam@nocrew.org> - 2015-11-24 08:55 +0100
Re: RfD: D>F and S>F first draft krishna.myneni@ccreweb.org - 2015-11-22 06:33 -0800
Re: RfD: D>F and S>F first draft anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-11-22 16:00 +0000
Re: RfD: D>F and S>F first draft krishna.myneni@ccreweb.org - 2015-11-22 08:53 -0800
Re: RfD: D>F and S>F first draft krishna.myneni@ccreweb.org - 2015-11-22 09:11 -0800
Re: RfD: D>F and S>F first draft anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-11-22 18:24 +0000
Re: RfD: D>F and S>F first draft Paul Rubin <no.email@nospam.invalid> - 2015-11-22 09:07 -0800
Re: RfD: D>F and S>F first draft stephen@mpeforth.com (Stephen Pelc) - 2015-11-22 18:10 +0000
Re: RfD: D>F and S>F first draft anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-11-22 18:26 +0000
Re: RfD: D>F and S>F first draft rickman <gnuarm@gmail.com> - 2015-11-22 13:58 -0500
Re: RfD: D>F and S>F first draft anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-11-23 12:34 +0000
Re: RfD: D>F and S>F first draft Albert van der Horst <albert@spenarnc.xs4all.nl> - 2015-11-23 16:39 +0000
Re: RfD: D>F and S>F first draft Bernd Paysan <bernd.paysan@gmx.de> - 2015-11-24 03:00 +0100
Re: RfD: D>F and S>F first draft Lars Brinkhoff <lars.spam@nocrew.org> - 2015-11-23 13:48 +0100
Re: RfD: D>F and S>F first draft mhx@iae.nl - 2015-11-23 05:19 -0800
Re: RfD: D>F and S>F first draft mhx@iae.nl - 2015-11-23 16:09 -0800
Re: RfD: D>F and S>F first draft Bernd Paysan <bernd.paysan@gmx.de> - 2015-11-22 20:42 +0100
Re: RfD: D>F and S>F first draft C G Montgomery <cgm@physics.utoledo.edu> - 2015-11-22 16:43 -0500
Re: RfD: D>F and S>F first draft krishna.myneni@ccreweb.org - 2015-11-22 18:40 -0800
Re: RfD: D>F and S>F first draft krishna.myneni@ccreweb.org - 2015-11-22 18:51 -0800
Re: RfD: D>F and S>F first draft C G Montgomery <cgm@physics.utoledo.edu> - 2015-11-25 15:47 -0500
Re: RfD: D>F and S>F first draft anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-11-22 14:29 +0000
Re: RfD: D>F and S>F first draft "David N. Williams" <williams@umich.edu> - 2015-11-22 10:41 -0600
csiph-web