|
|
вернуться в форумseveral tricky cases i failed at Послано Koala 6 ноя 2009 02:13 1) the exponent may be very large (absolute value). e.g. -100000000000000000000000000000000000. 2) the exponent may pretend to be very large, but actually not. e.g. 000000000000000000000000000000000010 3) 12.e1 is not a valid floating point number, because the dot cannot be the last character of the integral part according to the grammar mentioned. good luck Re: several tricky cases i failed at try also tests such as --1 1 Re: several tricky cases i failed at I used conversion String to BigDecimal in Java. But cases 1 and 3 (in Koala's message) should be processed separately. To process very large negative exponent I used the following String res; try { res = bd.toPlainString(); } catch (OutOfMemoryError e) { // gets here if exp < -1000000 res = "0.0"; // no need to keep any digits if exp < -200 } But I don't like it. And maybe it's wrong? Nevertheless I still have WA 12 :))) Edited by author 02.06.2010 13:54 |
|
|