Android Question Javascript Formula > B4a

daniedb

Active Member
Licensed User
Longtime User
Hi Guys

How wil this javascript be converted to B4A
I've tried the Logarithm keyword but still receive error
B4X:
var totdb  = 10 * (Math.log((Math.pow(alpha,2) - Math.pow(rho,2)) / (alpha * (1 - Math.pow(rho,2)))) / Math.LN10);
I've tried this...
B4X:
dim var as Float
' all variables alpha, rho, as floats
var = 10 * Logarithm((Power(alpha,2) - (Power(rho,2)) / (alpha * (1 - Power(rho,2))) / ^10)

Any help appreciated
 

DonManfred

Expert
Licensed User
Longtime User
i´m not sure but the () seems wrong...

maybe
B4X:
var = 10 *
(Logarithm((Power(alpha,2) - Power(rho,2)) / (alpha * (1 - Power(rho,2))) / ^10)
 
Upvote 0

daniedb

Active Member
Licensed User
Longtime User
i´m not sure but the () seems wrong...

maybe
B4X:
var = 10 *
(Logarithm((Power(alpha,2) - Power(rho,2)) / (alpha * (1 - Power(rho,2))) / ^10)

Tried that
Error return is
Error description: Input string was not in a correct format.

Thanks
 
Upvote 0

Roycefer

Well-Known Member
Licensed User
Longtime User
B4X:
^10
doesn't mean anything in B4X. And even if it did, it wouldn't be equivalent to JavaScript's Math.LN10. Furthermore, B4X's Logarithm() function requires two arguments: the number and the base.

Try this:
B4X:
Dim totdb as Double = 10*( Logarithm( (Power(alpha,2)-Power(rho,2))/(alpha*(1-Power(rho,2))), cE)/Logarithm(10, cE) )
 
Upvote 0

daniedb

Active Member
Licensed User
Longtime User
B4X:
^10
doesn't mean anything in B4X. And even if it did, it wouldn't be equivalent to JavaScript's Math.LN10. Furthermore, B4X's Logarithm() function requires two arguments: the number and the base.

Try this:
B4X:
Dim totdb as Double = 10*( Logarithm( (Power(alpha,2)-Power(rho,2))/(alpha*(1-Power(rho,2))), cE)/Logarithm(10, cE) )
Thanks, that did the job

Cheers
Danie
 
Upvote 0
Top