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

Data outputting to excel causes numbers to change

 
John Graham
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, i'm writing a program that calculates moments from a shape and writes the results to an excel spreadsheet, using the apache poi package

Anyway, i'm getting the correct figures its just when i write them to the spreadsheet, the figures mysteriously change, for example the program will produce a result like 8.092238721555691E-4, but in the spreadsheet its stored as 0.000809224....

To deepen the mystery some the figures are being stored correctly...

Has anyone any experience of something similar, or any suggestions?
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Those two things look like the same number, just represented in different ways. Doesn't look incorrect to me. But remembering that you can ask Excel and Java to format numbers in a variety of ways, what specific differences can you point out?

And, welcome to the Ranch!
 
John Graham
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul!

Yeah its seems to be the same number just with the decimal point in the wrong place.

Its only really the longer numbers that are affected, could this just be the way in which the cells of the excel document are formatted?
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, am I missing a factor of 10 or something? To me 8.09223E-4 looks the same as 0.000809223.
 
John Graham
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Indeed they are the same, the first is scientific notation for the second, the issue is that my program treats the 2 numbers as 2 completely different numbers, which causes problems when it comes to comparing the numbers.

Is there anyway to stop excel from changing the numbers?
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by Excel "changing" the numbers? And this program of yours which treats the two numbers as different, is it a Java program or an Excel macro or what?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic