• Post Reply Bookmark Topic Watch Topic
  • New Topic

Number format Problem - Please advise  RSS feed

 
Edward Durai
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Sir,

My input number is looks like 123456789

But using java program, if i read that number, i am getting 123456789.00

how can I avoid that.

Whatever I give the number, java should be display the same.
suppose if i give the input 123456789.00,
it should be displayed the same output.

Is it possible?

Please advise.
[ November 07, 2008: Message edited by: Edward Durai ]
 
Campbell Ritchie
Marshal
Posts: 56533
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We would need more details, but you would appear to be putting an int into a double. It would be possible to print a double without .00 if there is no fractional part, but the imprecision of floating-point arithmetic makes that unreliable.
 
Campbell Ritchie
Marshal
Posts: 56533
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could try using a BigDecimal to preserve the .00; read the API for BigDecimal and see what it says. Or you could preserve the entry as a String.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!