0

Hi there this operation give me undesired response , how i can get desired response from it ?

For example when a and second is equal :

a=a.subtract(second);

a=0.99999905050206647416680425521917641162872314453125

second=1.0

give me

a=-9.4949793352583319574478082358837127685546875E-7

but i don't want it and i want numerical value not ...E-7 . How i can solve this ? i tried this method but doesn't solve my problem.

a=a.setScale(15,RoundingMode.HALF_UP);
Michael Ghorb
  • 359
  • 4
  • 12
  • How have you created the instances of `BigDecimal`, using `double` or using a `String` with the proper value? – Luiggi Mendoza Oct 11 '15 at 21:46
  • 1
    Possible duplicate of [Why does Java BigDecimal return 1E+1?](http://stackoverflow.com/questions/925232/why-does-java-bigdecimal-return-1e1) – Andreas Oct 11 '15 at 21:56

1 Answers1

2

Use BigDecimal.toPlainString():

Returns a string representation of this BigDecimal without an exponent field.

Andreas
  • 154,647
  • 11
  • 152
  • 247