Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming > #889
| 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 10:56 +0000 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <j66rl4$4s1$1@speranza.aioe.org> (permalink) |
| References | (4 earlier) <slrn3vfsj7q32k.jl0.ike@sverige.freeshell.org> <lPednSOuSqKogODTnZ2dnUVZ_hednZ2d@earthlink.com> <j5kgme$rm8$1@dont-email.me> <j8-dnVxOZvxbe-DTnZ2dnUVZ_rqdnZ2d@earthlink.com> <c24870bd-913e-4dc0-a8b2-cd055f999f43@dm9g2000vbb.googlegroups.com> |
Cross-posted to 2 groups.
In comp.lang.pl1 Robin Vowels <robin.vowels@gmail.com> wrote: (snip, someone, somewhere, wrote) >> >>>>> What is the exact result of 1.6 * 1.6 (one decimal place) ? >> >>>> The exact result is 2.56. Why would you drop one digit? >> >>> Isn't that what fixed-point arithmetic is about? Having a fixed >> >>> number of digits after the decimal (or binary) point? One favorite PL/I example for many years is the expression 25+1/3. The value, surprisingly enough, is 5.3333333333 (with the exact number of 3's implementation dependent). This is a strange side-effect of the precision rules and the fact that constants have the attributed in which they are written. (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, again as for hand arithmetic. (As with integer multiply in other languages, digits may be lost in overflow unless FIXEDOVERFLOW is enabled.) 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. -- 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