Hi, i'm making histograms by dividing my range in a given number of bins and i've stumbled upon a problem that if it has no explanation, then i think is VERY bad. Below i post my code which will just calculate the bin limits for a given number of bins and a range which goes from x_min to x_max. And below it output with a high precision. The problem is that the precision of the output is unacceptably bad for only some of the iterations as displayed below the code
As you see the value of the variable range when it should be 14 (i=7) and 28 (i=14) is quite off. I found first the problem when running histogram functions from GSL, but finally traced it back to just a matter of dividing doubles. My machine is running ubuntu 9.10 (64-bit). I've tried also compiling it on a MAC machine and the error is consistently exactly the same as shown above every time the program is run. Also, if the doubles are changed to floats the error appears when range should be 30 (i=15). Please let me know if this s a known issue and how could it be solved. Should you need more information, please just let me know, but i think if you copy the code you'd be able to reproduce the problem without any complication.
Thanks in advance.
Thanks for the reply and the article refered above. I am aware that there are precision issues that we have to live with, so actually i am not concerned about the error in fauxi and fi variables. What i don't get here is why the values of range are rounded correctly for most of the cases except for when it should be 14 and 28. Would then these just be worst case precision scenarios?