This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: How to determine that 2.0 == (float) 2 in a front-end.
- From: Paul Koning <pkoning at equallogic dot com>
- To: tej at melbpc dot org dot au
- Cc: gcc at gcc dot gnu dot org
- Date: Thu, 27 Jun 2002 20:06:32 -0400
- Subject: Re: How to determine that 2.0 == (float) 2 in a front-end.
- References: <1025186349.2842.ezmlm@gcc.gnu.org><3D1B7611.70A274B5@melbpc.org.au>
>>>>> "Tim" == Tim Josling <tej@melbpc.org.au> writes:
Tim> I have come across situations where for example 2.0 ** N where N
Tim> > 240 was calculated by successive multiplications. This sort of
Tim> calculation is common in net present value calculations, where
Tim> you use binary search of Newton's method to zero in on the
Tim> correct interest rate given a set of payments. This is terribly
Tim> slow.
It shouldn't be all that slow if you remember that x**i can be done in
O(log2(i)) operations -- not O(i) operations.
paul