I get java.lang.NumberFormatException: For input line: "1.7023484830876092"
trimming the string to 1.70234 solves the problem, but before cutting the string, I wonder if some java methods can be used to use the capacity of the target.
Regards, Jeroen.
you can try using the DecimalFormat class:
http://download.oracle.com/javase/1.5.0/docs/api/java/text/DecimalFormat.html
DecimalFormat fm = new DecimalFormat("#.################"); try { double x = fm.parse("1.12345678901234").doubleValue(); System.out.println(x); } catch (ParseException e) { e.printStackTrace(); }
it might work.
It looks like a float. Moreover, the first "." is the only one.
, BigDecimal? , . new BigDecimal(stringNumber). , infix (, + - */etc...).
new BigDecimal(stringNumber)
But if you just want the largest value that the primitive can hold, use Long.MAX_VALUE
Long.MAX_VALUE
You cannot parse floating point values with Long.parseLong. Use Double.parseDouble instead.
Source: https://habr.com/ru/post/1785382/More articles:IO arguments versus side effects arguments - coding-styleLINQ query to Observable collection - c #Хэш-таблица с двумя первичными ключами - collectionsCan I create an application that edits the conatct list on iphone? - iphonedocumentum DQL command exec count_sessions - what do the columns "hot_list_size", "warm_list_size", "cold_list_size" mean? - dqlNSFileManager: copy file in atomic mode? - objective-cHow to assign shell variables inside sh -c "..." command? - variablesto scroll UIScrollview - objective-cПравильно ли использовать тег для отображения дат в HTML5 - htmlHow to run several external commands in the background in ruby - ruby | fooobar.comAll Articles