Friday 30 August 2013

A Little Hint on JAVA

Well people have been constantly asking me as to  HOW WE CAN LOG BASE 2 IN JAVA.

STEPS:~

Well, firstly, YOU CAN'T DIRECTLTY log base 2 in Java like in Python or C++.

This is how you do it:

int a = 100;
int log = Math.log10(a)/Math.log10(2);

CONCEPT:~

Well, what we are doing is we are first logging with base 10 and then dividing with 2 logged to base 10.
 
Hope you liked it.
The Ash.

No comments:

Post a Comment

Followers