 1
Whether a number is displayed in scientific notation or not, depends on how you let Java format and print the number. The easiest way to print a double value in "normal" notation is like this:
The mind is a strange and wonderful thing. I'm not sure that it will ever be able to figure itself out, everything else, maybe. From the atom to the universe, everything, except itself.
Bear Bibeault wrote:How are you printing it out?
I am trying to use it in an SQL string to add a record to a remote data base.
I got the scientific natation from the console as part of the message I got when it failed. I need to save it as a 10 digit integer. The number in the calculation is a 13 digit number(just trying to shrink it down to 10 digits).
Maybe you can explain exactly what the number is supposed to represent and what the calculation is supposed to do.
The mind is a strange and wonderful thing. I'm not sure that it will ever be able to figure itself out, everything else, maybe. From the atom to the universe, everything, except itself.
Stephan van Hulst wrote:If it's an integer, why are you using double?
Maybe you can explain exactly what the number is supposed to represent and what the calculation is supposed to do.
The following code generates a long number of 13 digits:
My remote data field is an integer type that holds 10 digits.
If I subtract 1490000000000 from the long number I get a 10 digit number.
However, when I use the result in my SQL string to insert the record the number is represented in scientific notation.
you are subtracting 1490000000000.00 off of the number, which is a double literal (because of the decimal point in the number). This means that the result of that whole calculation is double, a floatingpoint number, and not long, an integer.
If you need a long, then don't subtract a double value from the number; subtract a long value from the number instead:
Jesper de Jong wrote:Note that in your original line of code:
you are subtracting 1490000000000.00 off of the number, which is a double literal (because of the decimal point in the number). This means that the result of that whole calculation is double, a floatingpoint number, and not long, an integer.
If you need a long, then don't subtract a double value from the number; subtract a long value from the number instead:
Thanks, this works great. However, I did not consider my seed number growing as fast as it has. Now the number is 1500063579542 and subtracting the 1490000000000L yields an 11 digit number.
I need a way to reduce any 13 digit number down to 10 digits. Is there a way to strip the last 3 digits off?
Get off me! Here, read this tiny ad:
Thread Boost  a very different sort of advertising
https://coderanch.com/t/674455/ThreadBoostfeature
