kkh
kkh

Reputation: 4869

Float values in java

I have some float values in which i do some multiplication

However, the result is a -0, which I found out that the value is too small, hence converted to this answer.

I need to compare the different results which are of float, hence if its -0, I cannot do comparsion.

How can I resolve this? Many thanks in advance.

Upvotes: 2

Views: 231

Answers (3)

George
George

Reputation: 497

Try to use java.math.BigDecimal. The doc is right here: http://docs.oracle.com/javase/7/docs/api/java/math/BigDecimal.html

Upvotes: 0

Austin
Austin

Reputation: 4929

Try and use BigDecimal,

javadocs are here http://docs.oracle.com/javase/1.5.0/docs/api/java/math/BigDecimal.html

Upvotes: 3

Matthew Flaschen
Matthew Flaschen

Reputation: 284786

Try using double, which will give more precision. If that still isn't sufficient, you can use BigDecimal.

Upvotes: 1

Related Questions