what is the most efficient way to compute a logarithm in solidity? Is there a library that implements it or a built in function?

# [Ethereum] Logarithm math operation in Solidity

solidity

Skip to content
# [Ethereum] Logarithm math operation in Solidity

solidity

what is the most efficient way to compute a logarithm in solidity? Is there a library that implements it or a built in function?

## Best Answer

Though there's no current implementation (and I couldn't see one in the dapp-bin either), you could implement your own using a Taylor Series, as suggested by Vitalik in this old Reddit thread.

For the example in the thread, it effectively comes down to something like the following:

Bear in mind the number of steps and the associated gas cost...