Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming > #860

Re: calculating the power of a fixed point

Date 2011-09-24 07:18 -0700
From Patricia Shanahan <pats@acm.org>
Newsgroups comp.programming
Subject Re: calculating the power of a fixed point
References (4 earlier) <slrn3vfsj7osno.eca.ike@sverige.freeshell.org> <79114815-2bea-46d6-a3e6-273bdda34d14@e3g2000pri.googlegroups.com> <slrn3vfsj7q32k.jl0.ike@sverige.freeshell.org> <lPednSOuSqKogODTnZ2dnUVZ_hednZ2d@earthlink.com> <j5kgme$rm8$1@dont-email.me>
Message-ID <j8-dnVxOZvxbe-DTnZ2dnUVZ_rqdnZ2d@earthlink.com> (permalink)

Show all headers | View raw


On 9/24/2011 4:58 AM, BartC wrote:
>
>
> "Patricia Shanahan" <pats@acm.org> wrote in message
> news:lPednSOuSqKogODTnZ2dnUVZ_hednZ2d@earthlink.com...
>> On 9/23/2011 3:46 PM, Ike Naar wrote:
>>> On 2011-09-23, Robin Vowels<robin.vowels@gmail.com> wrote:
>>>> On Sep 23, 9:52?pm, Ike Naar<i...@sverige.freeshell.org> wrote:
>>>>> On 2011-09-23, Robin Vowels<robin.vow...@gmail.com> wrote:
>>>>>
>>>>>> On Sep 20, 10:36?pm, "Dmitry A. Kazakov"<mail...@dmitry-kazakov.de>
>>>>>> wrote:
>>>>>>> Fixed-point arithmetic is exact.
>>>>>
>>>>>> Not really. ?Addition, subtraction, and multiplication are.
>>>>>> However, division is not.
>>>>>
>>>>> 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?
>>
>> Yes, but if you want exactness you make sure that number of digits is
>> sufficient to store the exact answers.
>
> How does that work? If there are N digits after the point, then in
> general the result of a multiply will need up to 2N digits.
>

There are two meanings of "N digits after the point":

1. All non-zero digits after the point are in the first N digits.

2. N digits after the point are being stored.

 From your comment about needing 2N digits after the multiply I assume
you are using the first meaning. You would need to store the numbers
with 2N digits after the decimal point if you want exactness and plan to
multiply numbers with non-zeros in the first N digits.

Taking the quoted example, if you expected to square a number like 1.6,
with a non-zero digit after the decimal point you need to store the
numbers with 2 digits after the point. There is nothing preventing you
from storing 1.6 with a trailing zero.

The inconvenience of working out how many digits one needs to store not
only the inputs and final answer but any possible intermediate result is
a major motivation for using floating point arithmetic, and keeping an
exponent with each number.

Patricia

Back to comp.programming | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

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