What is equivalent for logf from C in JAVA?

106 views Asked by At

What is equivalent for logf from C in JAVA? Using math.h I have:

logf (extern float logf _PARAMS((float));) 

I want use float in JAVA.

Thank you for your advice and help!

2

There are 2 answers

0
Dellowar On BEST ANSWER

java.lang.Math.log(double a)

Given it does not use floats, but instead doubles. There is not native java support for logs on a float level.

0
oschlueter On

You're looking for Math.log(double e) which accepts and returns type double:

float log = (float) Math.log(1.0f);

By casting the result to float you obviously lose precision so you could just keep it as double:

double log = Math.log(1.0f);