user2074209
user2074209

Reputation: 23

Convert double from scientific notation

This is what I've tried.

long varOne = 902621492492L;
double varTwo = (double) varOne * 0.0001;
System.out.println(varTwo);

Output: 9.02621492492E7. Why isn't it 90262149.2492 and how do I fix it? Thanks!

Upvotes: 1

Views: 221

Answers (2)

AlexWien
AlexWien

Reputation: 28737

Output: 9.02621492492E7. and 90262149.2492 represent the same number.

Upvotes: 2

Matt Busche
Matt Busche

Reputation: 14333

should be able to do

long varOne = 902621492492L;
double varTwo = varOne.doubleValue() * 0.0001;
System.out.println(varTwo);

but from what I can tell 9.02621492492E7 is the answer.

Upvotes: 0

Related Questions