I found I can only do sqrt of a Float but not a Decimal.

I have to put f into the variable value to make it work.

e.g: 3.0 must be written as 3.0f in order to have sqrt working.

So how to do sqrt of a Decimal?

Decimal wraps Java's BigDecimal - which unfortunately doesn't have a square root method.

Also see Square root of BigDecimal in Java on StackOverflow.

Now it's clear. Thanks.

Login or Signup to reply.

## CretinHo Tue 15 Jun

I found I can only do sqrt of a Float but not a Decimal.

I have to put f into the variable value to make it work.

e.g: 3.0 must be written as 3.0f in order to have sqrt working.

So how to do sqrt of a Decimal?

## SlimerDude Tue 15 Jun

Decimal wraps Java's BigDecimal - which unfortunately doesn't have a square root method.

Also see Square root of BigDecimal in Java on StackOverflow.

## CretinHo Tue 15 Jun

Now it's clear. Thanks.