Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming > #892
| From | glen herrmannsfeldt <gah@ugcs.caltech.edu> |
|---|---|
| Newsgroups | comp.programming, comp.lang.pl1 |
| Subject | Re: calculating the power of a fixed point |
| Date | 2011-10-01 18:04 +0000 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <j67knj$51h$1@speranza.aioe.org> (permalink) |
| References | (4 earlier) <j5kgme$rm8$1@dont-email.me> <j8-dnVxOZvxbe-DTnZ2dnUVZ_rqdnZ2d@earthlink.com> <c24870bd-913e-4dc0-a8b2-cd055f999f43@dm9g2000vbb.googlegroups.com> <j66rl4$4s1$1@speranza.aioe.org> <3e450ec1-bb71-4f48-9d90-3b00212167cf@g23g2000vbz.googlegroups.com> |
Cross-posted to 2 groups.
In comp.lang.pl1 Robin Vowels <robin.vowels@gmail.com> wrote: > On Oct 1, 8:56 pm, glen herrmannsfeldt <g...@ugcs.caltech.edu> wrote: >> One favorite PL/I example for many years is the expression 25+1/3. >> >> The value, surprisingly enough, is 5.3333333333 > No it's not. That "example" has been bandied about by those > ignorant of PL/I. > The outcome is fixed-point overflow, which is detected by > the PL/I run-time. Unless, of course it has a (NOFIXEDOVERFLOW): prefix. >> (with the exact >> number of 3's implementation dependent). > Only to the extent determined by hardware (wordsize or maximum field > width). >> This is a strange >> side-effect of the precision rules and the fact that constants >> have the attributed in which they are written. > 'attributes', not 'attributed'. Missed by that much. >> (For those worried about the answer, try 25+01/3 instead.) >> >> Addition and subtraction give the number of digits after the >> radix point as the maximum of the two operands, as one would >> do in hand arithmetic. Multiply gives the sum of the digits >> after the radix point, (snip) > In short, the product accommodates the entire product, > subject to the maximum word size or field width available. If the > result exceeds the maximum, overflow occurs, and is detected by the > run-time. Unless FIXEDOVERFLOW is disabled. But note that the number of digits available for the product is fixed at compile time. The rules allow for the appopriate number of digits to the right of the of the radix point. Number of digits to the left is subject to the implementation maximum. > I should point out that the programmer can specify the precision of > the result (including the number of digits after the radix point). >> again as for hand arithmetic. (As with >> integer multiply in other languages, digits may be lost in >> overflow unless FIXEDOVERFLOW is enabled.) > FIXEDOVERFLOW and SIZE would normally be enabled. Unless they are disabled. >> There is no easy answer for the scale factor in division, though. >> Look it up in the manual, and you will find why the above expression >> gives the value that it does. > On the contrary, it's simple. Fixed-point division delivers the > maximum accuracy possible. Well, the rules have to balance between digits left and right of the radix point. There is, in general, no right answer. > That said, it is usual to specify for division the number of digits > to be maintained after the radix point. -- glen
Back to comp.programming | Previous | Next — Previous in thread | Next in thread | Find similar
calculating the power of a fixed point Keren Davidpur <kerenpur@gmail.com> - 2011-09-20 02:00 -0700
Re: calculating the power of a fixed point "BartC" <bc@freeuk.com> - 2011-09-20 12:01 +0100
Re: calculating the power of a fixed point "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2011-09-20 14:36 +0200
Re: calculating the power of a fixed point Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-09-21 03:52 +0100
Re: calculating the power of a fixed point "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2011-09-21 10:36 +0200
Re: calculating the power of a fixed point Robin Vowels <robin.vowels@gmail.com> - 2011-09-23 04:03 -0700
Re: calculating the power of a fixed point Ike Naar <ike@sverige.freeshell.org> - 2011-09-23 11:52 +0000
Re: calculating the power of a fixed point Robin Vowels <robin.vowels@gmail.com> - 2011-09-23 08:59 -0700
Re: calculating the power of a fixed point Ike Naar <ike@sverige.freeshell.org> - 2011-09-23 22:46 +0000
Re: calculating the power of a fixed point Patricia Shanahan <pats@acm.org> - 2011-09-23 16:58 -0700
Re: calculating the power of a fixed point "BartC" <bc@freeuk.com> - 2011-09-24 12:58 +0100
Re: calculating the power of a fixed point Patricia Shanahan <pats@acm.org> - 2011-09-24 07:18 -0700
Re: calculating the power of a fixed point Jongware <jongware@no-spam.plz> - 2011-09-26 11:03 +0200
Re: calculating the power of a fixed point "BartC" <bc@freeuk.com> - 2011-09-26 10:40 +0100
Re: calculating the power of a fixed point Robin Vowels <robin.vowels@gmail.com> - 2011-10-01 03:51 -0700
Re: calculating the power of a fixed point Robin Vowels <robin.vowels@gmail.com> - 2011-10-01 03:44 -0700
Re: calculating the power of a fixed point glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2011-10-01 10:56 +0000
Re: calculating the power of a fixed point Robin Vowels <robin.vowels@gmail.com> - 2011-10-01 07:00 -0700
Re: calculating the power of a fixed point glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2011-10-01 18:04 +0000
Re: calculating the power of a fixed point Robin Vowels <robin.vowels@gmail.com> - 2011-10-01 16:27 -0700
Re: calculating the power of a fixed point Robin Vowels <robin.vowels@gmail.com> - 2011-10-02 00:19 -0700
Re: calculating the power of a fixed point Robin Vowels <robin.vowels@gmail.com> - 2011-10-02 00:24 -0700
Re: calculating the power of a fixed point Dann Corbit <dcorbit@connx.com> - 2011-09-20 12:09 -0700
Re: calculating the power of a fixed point Robin Vowels <robin.vowels@gmail.com> - 2011-09-22 03:21 -0700
Re: calculating the power of a fixed point Robin Vowels <robin.vowels@gmail.com> - 2011-09-23 04:07 -0700
Re: calculating the power of a fixed point Peter Flass <Peter_Flass@Yahoo.com> - 2011-09-23 08:17 -0400
Re: calculating the power of a fixed point Robin Vowels <robin.vowels@gmail.com> - 2011-09-23 08:30 -0700
Re: calculating the power of a fixed point glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2011-09-23 12:39 +0000
Re: calculating the power of a fixed point Robin Vowels <robin.vowels@gmail.com> - 2011-09-23 08:44 -0700
Re: calculating the power of a fixed point glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2011-09-23 17:07 +0000
Re: calculating the power of a fixed point Robin Vowels <robin.vowels@gmail.com> - 2011-09-23 19:17 -0700
csiph-web