Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A question about double type

 
YuenLian Wu
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am currently using double to sum up a bunch of big number with decimal places. I try to export some data in csv format, and one of the field belong to what I just said. However, i see 7.8923932482495E9(for example) in my csv file. I am wonder how can I get the number completely, e.g 78923932482495.79. My friend tell me to use BigDecimal class, however, I only see it has some functions to wrap up the long data type. "long" is not what I want since my field has decimal places.

Can anybody give me suggestions to solve this question?

Myriads Thanks

Transistor
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you print your numbers, you have to format them deliberately the way you want them, or be happy with the default. The way to format numbers deliberately is with the java.text.DecimalFormat class.

I'm moving this to Java in General (Intermediate.)
 
YuenLian Wu
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
seems cooL, thanks....
 
Garrett Rowe
Ranch Hand
Posts: 1296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My friend tell me to use BigDecimal class, however, I only see it has some functions to wrap up the long data type...
What in the documentation gave you that idea. Even the name BigDecimal should give you some indication of the type of operations this class was created for.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic