'How to implement Log base 2 in flutter?

How can I find Log2(x) in flutter?

I didn't found the match function in flutter math package

Note:

Log base 2



Solution 1:[1]

As the others said, you can use the Logarithm change of base formula .

import 'dart:math';

double logBase(num x, num base) => log(x) / log(base);
double log2(num x) => logBase(x, 2);

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 quoci