How can I find Log2(x) in flutter?
I didn't found the match function in flutter math package
Note:
Log base 2
How can I find Log2(x) in flutter?
I didn't found the match function in flutter math package
Note:
Log base 2
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);
As others mentioned, implementing log base X is a one-liner, but if you'd rather someone else write that one line, then take a look at the Dart Basic Utils package which has this implemented. Specifically, see the MathUtils section: https://github.com/Ephenodrom/Dart-Basic-Utils#mathutils
Disclaimer: I'm the one who contributed said functionality.