Re: how to specify power of number



"Dann Corbit" <dcorbit@xxxxxxxxx> wrote in message
news:14653$480920eb$8464@xxxxxxxxxxxxxxxxxxxx
[snip]

Because math coprocessors are awfully fast now, I guess that pow(2.0,k) is
nearly as fast as bit shifts and additions, but there is a bigger problem
with using pow(2,x) to find exact powers of 2. It should not be
unexpected for pow(2.0,24) to return 16777215.999999999 and if you assign
that to an integer, it probably won't be what is wanted unless you are
clever enough to round it -- ceil() won't help either because we might
also have seen 16777215.0000001 or something like that. The Cephes
collection of math

Of course I meant 16777216.0000001 -- I would be pretty upset with a double
math library that can't even give me back 8 significant digits of precision.

functions {for instance} uses a ratio of a cubic polynomial divided by a
quartic polynomial to form the approximation.
[snip]


** Posted from http://www.teranews.com **
.



Relevant Pages

  • Re: how to specify power of number
    ... nearly as fast as bit shifts and additions, but there is a bigger problem ... with using powto find exact powers of 2. ...  The Cephes collection of math ... integral exponents, so as to handle negative operands, as well as provide ...
    (comp.lang.c)
  • Re: Dynamically resizing a buffer
    ... years spent programming in high level languages where I would not. ... I use shifts where I think shifts, I had never thought to think divides... ... representation level, ...
    (comp.lang.c)
  • Re: Attn: Atheists & Skeptics - Whats wrong with answersingenesis.com?
    ... > Expansion redshifts _are_ Doppler redshifts. ... Doppler shifts are caused by relative motion within space ...
    (talk.origins)
  • Re: Dynamically resizing a buffer
    ... years spent programming in high level languages where I would not. ... I always used shifts, ... visual representations of the expressions, ...
    (comp.lang.c)
  • Re: Saving clock format on RISC OS 6
    ... available with organizer. ... Well, I have alarms set in Organiser for each working day, but as I ... don't work regular Monday-Friday shifts, I simply set up a set of ...
    (comp.sys.acorn.apps)