How to convert numbers 2.15600e + 03 (euler) to numeric type?

2

I have the following problem: I have to read a file that contains several very large numbers as shown below.

When you try to read them and send them to a variable double / long / int, the error acknowledges that it is a string . I would like to know how to convert this type of number to double / long / int (whichever applies in this case).

    
asked by anonymous 07.05.2015 / 12:37

1 answer

3

Use the Double class to do the conversion:

To long :

long longVar = Double.valueOf("2.15600e+03").longValue();

To double :

double doubleVar = Double.valueOf("2.15600e+03").doubleValue();
    
07.05.2015 / 12:53