Use native cbrt implementation on JVM and native platforms
diff --git a/src/commonMain/kotlin/dev/kdrag0n/colorkt/util/math/MathExt.kt b/src/commonMain/kotlin/dev/kdrag0n/colorkt/util/math/MathExt.kt
index 61408c4..3618f7f 100644
--- a/src/commonMain/kotlin/dev/kdrag0n/colorkt/util/math/MathExt.kt
+++ b/src/commonMain/kotlin/dev/kdrag0n/colorkt/util/math/MathExt.kt
@@ -9,7 +9,9 @@
internal inline fun cube(x: Double) = x * x * x
internal inline fun square(x: Double) = x * x
-internal fun cbrt(x: Double) = when {
+internal expect fun cbrt(x: Double): Double
+
+internal fun cbrtPowImpl(x: Double) = when {
x > 0 -> x.pow(1.0 / 3.0)
x < 0 -> -(-x).pow(1.0 / 3.0)
else -> 0.0
diff --git a/src/jsMain/kotlin/dev/kdrag0n/colorkt/util/math/cbrt.kt b/src/jsMain/kotlin/dev/kdrag0n/colorkt/util/math/cbrt.kt
new file mode 100644
index 0000000..c5e97ed
--- /dev/null
+++ b/src/jsMain/kotlin/dev/kdrag0n/colorkt/util/math/cbrt.kt
@@ -0,0 +1,3 @@
+package dev.kdrag0n.colorkt.util.math
+
+internal actual fun cbrt(x: Double) = cbrtPowImpl(x)
diff --git a/src/jvmMain/kotlin/dev/kdrag0n/colorkt/util/math/cbrt.kt b/src/jvmMain/kotlin/dev/kdrag0n/colorkt/util/math/cbrt.kt
new file mode 100644
index 0000000..ca356e2
--- /dev/null
+++ b/src/jvmMain/kotlin/dev/kdrag0n/colorkt/util/math/cbrt.kt
@@ -0,0 +1,3 @@
+package dev.kdrag0n.colorkt.util.math
+
+internal actual fun cbrt(x: Double) = Math.cbrt(x)
diff --git a/src/nativeMain/kotlin/dev/kdrag0n/colorkt/util/math/cbrt.kt b/src/nativeMain/kotlin/dev/kdrag0n/colorkt/util/math/cbrt.kt
new file mode 100644
index 0000000..9eeec90
--- /dev/null
+++ b/src/nativeMain/kotlin/dev/kdrag0n/colorkt/util/math/cbrt.kt
@@ -0,0 +1,3 @@
+package dev.kdrag0n.colorkt.util.math
+
+internal actual fun cbrt(x: Double) = platform.posix.cbrt(x)