java - Program crashes when given high values -
my coding, im trying make program wont crash whatever input user, program divide , print out answer. have searched not find help! coding works fine numbers smaller 100000000 or 199999999 point.
scanner in = new scanner(system.in); double n1 = in.nextint(); double n2 = in.nextint(); double n3 = n1/n2; system.out.println(n3);
you using in.nextint()
read integer value less 2^31 -1
(of course gets converted double
). when give values more (2^31) - 1
12589691475
, nextint()
can not read them big numbers.
use in.nextdouble()
instead.
Comments
Post a Comment