To compute the sqrt, we can use the Newton-Raphson method to converge to a sqrt. Newton serie is: x_(i+1) = x_i – f(x_i)/f’(x_i) for the sqrt we have: sqrt(n) = x or n = x^2 our newton function f(x) becomes: f(x) = x^2 – n. and first derivative: f’(x) = 2x; with our particular f(x), […]

~ read more ~## Posts tagged assembly

# Log2(n) tricks

How to fast compute log2(n) ? We are going to explore few methods. 1)The obvious: var log2:int = Math.log(n)*Math.LOG2E This is going to be incredibly slow, due to the function call, so lets try other methods described in http://graphics.stanford.edu/~seander/bithacks.html, and add some salt to them. 2)Log2 with branch One idea is to divide the number […]

~ read more ~# Local Variables versus Alchemy versus VM Stack ?

Today, we are going to look at the integer modulo operator. This is just a pretext to answer this question: what is faster: * locals variables * alchemy opcode used instead of locals variables * locals variables manipulated and kept on the VM stack So lets go back to the “Integer Modulo”, or %. A […]

~ read more ~
## Recent Comments