[Wasm] Fix stdlib String to Float parse
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
package kotlin.text
|
||||
|
||||
import kotlin.math.abs
|
||||
|
||||
import kotlin.wasm.internal.wasm_f32_demote_f64
|
||||
/**
|
||||
* Returns `true` if the content of this string is equal to the word "true", ignoring case, and `false` otherwise.
|
||||
*/
|
||||
@@ -84,13 +84,13 @@ public actual fun String.toDouble(): Double = kotlin.text.parseDouble(this)
|
||||
* Parses the string as a [Float] number and returns the result.
|
||||
* @throws NumberFormatException if the string is not a valid representation of a number.
|
||||
*/
|
||||
public actual fun String.toFloat(): Float = toDouble() as Float
|
||||
public actual fun String.toFloat(): Float = wasm_f32_demote_f64(toDouble())
|
||||
|
||||
/**
|
||||
* Parses the string as a [Float] number and returns the result
|
||||
* or `null` if the string is not a valid representation of a number.
|
||||
*/
|
||||
public actual fun String.toFloatOrNull(): Float? = toDoubleOrNull() as Float?
|
||||
public actual fun String.toFloatOrNull(): Float? = toDoubleOrNull()?.let { wasm_f32_demote_f64(it) }
|
||||
|
||||
/**
|
||||
* Parses the string as a [Double] number and returns the result
|
||||
|
||||
Reference in New Issue
Block a user