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

Asked

Viewed 204 times

2

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

inserir a descrição da imagem aqui

When trying to read them and send to a variable double/long/int, the error accusing it is a string. I would like to know how to convert this type of number into double/long/int (whichever is applicable in this case).

1 answer

3


Use the class Double to make the conversion:

To long:

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

To double:

double doubleVar = Double.valueOf("2.15600e+03").doubleValue();

Browser other questions tagged

You are not signed in. Login or sign up in order to post.