In one of my Java projects I am using double
values to perform cosine similarity calculations.
This is the formula:
cosine = (v1 × v2)/(|v1| × |v2|).
So, in my case both numerator and denominator (after vector simplification) are doubles. After analysing my code looking for optimizations or where time is consuming, I got that the division operation (for double values) is taking more time for execution.
I tried finding different ways of dividing two numbers (using bitwise [As bitwise operators are faster])
I came across this link Division without using / operator but it is for integer or long only.
So, my questions are
How can I improve the performance of division operation (for doubles) using alternative methods?
If the compiler converts the double values into binary numbers while performing arithmetic operations, how does division takes place for doubles or floats? I need a bit of explanation at machine level