POV-Ray : Newsgroups : povray.off-topic : Bounding circle intersection : Re: Bounding circle intersection Server Time
5 Sep 2024 01:19:04 EDT (-0400)
  Re: Bounding circle intersection  
From: Invisible
Date: 11 Dec 2009 04:08:31
Message: <4b220c0f$1@news.povray.org>
>>   Suppose that the most significant non-zero digit of x is in the 2^n 
>> place. Let y = x / 2^(n/2). Now Sqrt(x) is approximately x / y.
> 
> Is there a way to quickly get n for a given number?

If you don't mind depending on a specific floating-point 
representation... sure. Just find out which bits of the number contain 
the exponent. (For example, for a double-precision IEEE float, the 
bitmask is 0x7FFF000000000000, and you then shift out those zeros and 
subtract 0x3FFF to get the real value.)

That's what makes this so efficient. You just need the exponent field 
from the float value, so no need to calculate anything. (Indeed, as an 
even rougher approximation, just halve the exponent...)


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.