Real Close to the Machine: Floating Point in D

Don nospam at nospam.com
Wed May 13 11:26:59 PDT 2009


Lu’ís Marques wrote:
>> A naive binary chop doesn't work correctly. The fact that there are 
>> hundreds or thousands of times as many representable numbers between 0 
>> and 1, as there are between 1 and 2, is problematic for 
>> divide-and-conquer algorithms. A naive binary chop would divide the 
>> interval [0 .. 2] into [0 .. 1] and [1 .. 2]. Unfortunately, this is 
>> not a true binary chop, because the interval [0 .. 1] contains more 
>> than 99% of the representable numbers from the original interval!
> 
> How about adding a template to do a binary chop (binary search?) to 
> std.algorithm?

findRoot() (which needs to be updated to take advantage of compiler 
improvements) does the job in the most important case. I'm quite proud 
of it; as far as I know, it's uses a better algorithm than anything else 
on the planet. <g>




More information about the Digitalmars-d mailing list