Expressions with BigDecimal Java / Kotlin

I need help from those who understand Java / Kotlin.

I would like to perform some calculations with BigDecimal

How would the expression below look using BigDecimal?

(1 + 0.02) ^ (1 / 251) - 1

I tried to do like this:

val x = (BigDecimal.ONE + BigDecimal(0.02)).pow(1/251) - 1

However, dividing 1 by 251 is not accurate and this expression always returns 0



from Recent Questions - Stack Overflow https://ift.tt/2M3T7Qu
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Hibernate Search - Elasticsearch with JSON manipulation

Spring Elasticsearch Operations