Dávid Szegedi
Dávid Szegedi

Reputation: 13

Java 1.7 - with Math.log function

I write this line in my code:

szo.P_POS = Math.log( ((double) (szo.talalatok_szama_POS_blokkban) / (double)(szo.osszes_talalat_szama)) );

Variables szo.talalatok_szama_POS_blokkban and szo.osszes_talalat_szama are int member of szo inner class

And when I run it, I get different value from the actual value

Example:

System.out.println(Math.log((double)0.6));

this line evaluate to -0.5108256237659907

and actual value is: -0,22184874961635636749123320202039 (Windows Calculator)

Upvotes: 0

Views: 98

Answers (2)

Christian Tapia
Christian Tapia

Reputation: 34166

It seems like you want a base 10 logarithm:

Math.log10(x);

Upvotes: 3

Louis Wasserman
Louis Wasserman

Reputation: 198321

What base of logarithm is each version using? Java's Math.log uses base e, or ln in common math terms.

Upvotes: 1

Related Questions