Assuming i have some decimal fraction of unknown length AND without the integral part:
0.123 [3]
OR
0.0200405 [7]
OR
0.0000000987 [10]
etc
I have 'that' fraction as a C string (after convertion with the sprintf
) AND as a long double
(after using modfl
). I take word that in a columns because this two fractions can easily differ (due to the precison penalty involved).
What I have tried:
There is obvious way to do that using a simple cycle, but may be there is a better way to do this? I am thinking of using binary search, which should probably be faster (AND also mostly ignores precison penalty), reducing time complexity form O(n) to the O(log(n)), but is there a way to do it with the constant complexity (for example, if a have an integral number, i can simply use log10 intrinstic)?