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?

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

Joined: Feb 18, 2014
Posts: 3

posted

0

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?

Sorry, am I missing a factor of 10 or something? To me 8.09223E-4 looks the same as 0.000809223.

John Graham
Greenhorn

Joined: Feb 18, 2014
Posts: 3

posted

0

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?

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?