0

Hi
I have double values like this,

  double value1  = 100.0
  double value2  = 100.23

I need to convert like this,

  value1  = 100
  value2  = 100.23

Kindly give some sugesstions to convert like this.

4
Contributors
6
Replies
16
Views
4 Years
Discussion Span
Last Post by stultuske
0

ehm, seems to me you could use a DecimalFormat, that returns a String dependent on whether there are numbers after the decimal point or not.

0

Venkatesh: no, it might not. did you see the .23 for the second number? good luck in getting that in an int.

Edited by stultuske

0

M.Mahajna: you may want to re-read the original question. I think you didn't quite understood what he's looking for. his point is to only have decimals if there are decimal numbers.

0

M.Mahajna: you may want to re-read the original question. I think you didn't quite understood what he's looking for. his point is to only have decimals if there are decimal numbers.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.