• Post Reply Bookmark Topic Watch Topic
  • New Topic

Double data type outputting to an exponent  RSS feed

 
Vance Rodriguez
Greenhorn
Posts: 5
Eclipse IDE Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys!

I recently posted on here as I was struggling to use BufferedReader to extract some data and then perform some calculations and then have the results as outputs.
I haven't quite solved that issue but in order to progress, I hard coded some values into my application and proceeded with the actual calculation loops etc.

Currently, the value out put from one of my calculations is given as:
1.1704926E7

How can I make the console show it in a natural way. I've performed the calculation manually and it should be 11704926.5
I don't want to lose that .5!

Thanks in advance!
V
 
Paul Clapham
Sheriff
Posts: 22813
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you show us the code which formats that double value?
 
Campbell Ritchie
Marshal
Posts: 56518
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Find the Java Tutorials. Find the section about formatting numeric output. Here it is
Also read the specification for System.out.println. Actually that has lots of links which eventually lead you to this←read me. Since your output is > 10⁷, it is converted automatically to “computerised scientific notation”.
 
Robert D. Smith
Ranch Hand
Posts: 221
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vance Rodriguez wrote:Hi guys!

I recently posted on here as I was struggling to use BufferedReader to extract some data and then perform some calculations and then have the results as outputs.
I haven't quite solved that issue but in order to progress, I hard coded some values into my application and proceeded with the actual calculation loops etc.

To be honest, I think you should go back and revisit this problem; resolve it before moving on. In programming (and learning in general), each step builds upon the last. To move on by taking shortcuts, you are only hurting yourself and getting into some terrible habits. As Yoda would say, "Down the dark path you walk, yes."

Regards,
Robert
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!