if you get `NumberFormatException` than your strin...
# android
b
if you get
NumberFormatException
than your string probably isn't able to be represented as a
Long
k
Copy code
val numb = "1000.0"
    val amount : Int = numb.toInt()
    println("amonnn $" +amount.toString())
that wat am having am getting
NumberFormatException.forInputString
b
because it's a floating point number
try
.toFloat()
or
.toDouble()
m
Copy code
fun String.takeInt() : Int {
    val str = takeWhile { it.isDigit() }
    return if (str.isEmpty()) 0 else str.toInt()
}
b
or just
.toDouble().toInt()
m
For strings like "1200MHz" :)
b
what about "12,300"
k
thanks ..it worked
toDouble().toInt()