withSign
Returns this value with the sign bit same as of the sign value.
If sign is NaN the sign of the result is undefined.
Since Kotlin
1.2Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(3.14.withSign(3.14)) // 3.14
println(3.14.withSign(-3.14)) // -3.14
println((-3.14).withSign(-3.14)) // -3.14
println((-3.14).withSign(0.0)) // 3.14
println(Double.NaN.withSign(-1.0)) // NaN
//sampleEnd
}Returns this value with the sign bit same as of the sign value.
Since Kotlin
1.2Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(3.14.withSign(100)) // 3.14
println(3.14.withSign(-100)) // -3.14
println((-3.14).withSign(-100)) // -3.14
println((-3.14).withSign(0)) // 3.14
println(Double.NaN.withSign(-1)) // NaN
//sampleEnd
}Returns this value with the sign bit same as of the sign value.
If sign is NaN the sign of the result is undefined.
Since Kotlin
1.2Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(3.14f.withSign(3.14f)) // 3.14
println(3.14f.withSign(-3.14f)) // -3.14
println((-3.14f).withSign(-3.14f)) // -3.14
println((-3.14f).withSign(0.0f)) // 3.14
println(Float.NaN.withSign(-1.0f)) // NaN
//sampleEnd
}Returns this value with the sign bit same as of the sign value.
Since Kotlin
1.2Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(3.14f.withSign(100)) // 3.14
println(3.14f.withSign(-100)) // -3.14
println((-3.14f).withSign(-100)) // -3.14
println((-3.14f).withSign(0)) // 3.14
println(Float.NaN.withSign(-1)) // NaN
//sampleEnd
}Returns this value with the sign bit same as of the sign value.
If sign is NaN the sign of the result is undefined.
Since Kotlin
1.2Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(3.14.withSign(3.14)) // 3.14
println(3.14.withSign(-3.14)) // -3.14
println((-3.14).withSign(-3.14)) // -3.14
println((-3.14).withSign(0.0)) // 3.14
println(Double.NaN.withSign(-1.0)) // NaN
//sampleEnd
}Returns this value with the sign bit same as of the sign value.
Since Kotlin
1.2Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(3.14.withSign(100)) // 3.14
println(3.14.withSign(-100)) // -3.14
println((-3.14).withSign(-100)) // -3.14
println((-3.14).withSign(0)) // 3.14
println(Double.NaN.withSign(-1)) // NaN
//sampleEnd
}Returns this value with the sign bit same as of the sign value.
If sign is NaN the sign of the result is undefined.
Since Kotlin
1.2Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(3.14f.withSign(3.14f)) // 3.14
println(3.14f.withSign(-3.14f)) // -3.14
println((-3.14f).withSign(-3.14f)) // -3.14
println((-3.14f).withSign(0.0f)) // 3.14
println(Float.NaN.withSign(-1.0f)) // NaN
//sampleEnd
}Returns this value with the sign bit same as of the sign value.
Since Kotlin
1.2Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(3.14f.withSign(100)) // 3.14
println(3.14f.withSign(-100)) // -3.14
println((-3.14f).withSign(-100)) // -3.14
println((-3.14f).withSign(0)) // 3.14
println(Float.NaN.withSign(-1)) // NaN
//sampleEnd
}Returns this value with the sign bit same as of the sign value.
If sign is NaN the sign of the result is undefined.
Since Kotlin
1.2Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(3.14.withSign(3.14)) // 3.14
println(3.14.withSign(-3.14)) // -3.14
println((-3.14).withSign(-3.14)) // -3.14
println((-3.14).withSign(0.0)) // 3.14
println(Double.NaN.withSign(-1.0)) // NaN
//sampleEnd
}Returns this value with the sign bit same as of the sign value.
Since Kotlin
1.2Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(3.14.withSign(100)) // 3.14
println(3.14.withSign(-100)) // -3.14
println((-3.14).withSign(-100)) // -3.14
println((-3.14).withSign(0)) // 3.14
println(Double.NaN.withSign(-1)) // NaN
//sampleEnd
}Returns this value with the sign bit same as of the sign value.
If sign is NaN the sign of the result is undefined.
Since Kotlin
1.2Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(3.14f.withSign(3.14f)) // 3.14
println(3.14f.withSign(-3.14f)) // -3.14
println((-3.14f).withSign(-3.14f)) // -3.14
println((-3.14f).withSign(0.0f)) // 3.14
println(Float.NaN.withSign(-1.0f)) // NaN
//sampleEnd
}Returns this value with the sign bit same as of the sign value.
Since Kotlin
1.2Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(3.14f.withSign(100)) // 3.14
println(3.14f.withSign(-100)) // -3.14
println((-3.14f).withSign(-100)) // -3.14
println((-3.14f).withSign(0)) // 3.14
println(Float.NaN.withSign(-1)) // NaN
//sampleEnd
}Returns this value with the sign bit same as of the sign value.
If sign is NaN the sign of the result is undefined.
Since Kotlin
1.3Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(3.14.withSign(3.14)) // 3.14
println(3.14.withSign(-3.14)) // -3.14
println((-3.14).withSign(-3.14)) // -3.14
println((-3.14).withSign(0.0)) // 3.14
println(Double.NaN.withSign(-1.0)) // NaN
//sampleEnd
}Returns this value with the sign bit same as of the sign value.
Since Kotlin
1.3Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(3.14.withSign(100)) // 3.14
println(3.14.withSign(-100)) // -3.14
println((-3.14).withSign(-100)) // -3.14
println((-3.14).withSign(0)) // 3.14
println(Double.NaN.withSign(-1)) // NaN
//sampleEnd
}Returns this value with the sign bit same as of the sign value.
If sign is NaN the sign of the result is undefined.
Since Kotlin
1.3Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(3.14f.withSign(3.14f)) // 3.14
println(3.14f.withSign(-3.14f)) // -3.14
println((-3.14f).withSign(-3.14f)) // -3.14
println((-3.14f).withSign(0.0f)) // 3.14
println(Float.NaN.withSign(-1.0f)) // NaN
//sampleEnd
}Returns this value with the sign bit same as of the sign value.
Since Kotlin
1.3Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(3.14f.withSign(100)) // 3.14
println(3.14f.withSign(-100)) // -3.14
println((-3.14f).withSign(-100)) // -3.14
println((-3.14f).withSign(0)) // 3.14
println(Float.NaN.withSign(-1)) // NaN
//sampleEnd
}Returns this value with the sign bit same as of the sign value.
If sign is NaN the sign of the result is undefined.
Since Kotlin
1.8Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(3.14.withSign(3.14)) // 3.14
println(3.14.withSign(-3.14)) // -3.14
println((-3.14).withSign(-3.14)) // -3.14
println((-3.14).withSign(0.0)) // 3.14
println(Double.NaN.withSign(-1.0)) // NaN
//sampleEnd
}Returns this value with the sign bit same as of the sign value.
Since Kotlin
1.8Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(3.14.withSign(100)) // 3.14
println(3.14.withSign(-100)) // -3.14
println((-3.14).withSign(-100)) // -3.14
println((-3.14).withSign(0)) // 3.14
println(Double.NaN.withSign(-1)) // NaN
//sampleEnd
}Returns this value with the sign bit same as of the sign value.
If sign is NaN the sign of the result is undefined.
Since Kotlin
1.8Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(3.14f.withSign(3.14f)) // 3.14
println(3.14f.withSign(-3.14f)) // -3.14
println((-3.14f).withSign(-3.14f)) // -3.14
println((-3.14f).withSign(0.0f)) // 3.14
println(Float.NaN.withSign(-1.0f)) // NaN
//sampleEnd
}Returns this value with the sign bit same as of the sign value.
Since Kotlin
1.8Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(3.14f.withSign(100)) // 3.14
println(3.14f.withSign(-100)) // -3.14
println((-3.14f).withSign(-100)) // -3.14
println((-3.14f).withSign(0)) // 3.14
println(Float.NaN.withSign(-1)) // NaN
//sampleEnd
}Returns this value with the sign bit same as of the sign value.
If sign is NaN the sign of the result is undefined.
Since Kotlin
1.8Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(3.14.withSign(3.14)) // 3.14
println(3.14.withSign(-3.14)) // -3.14
println((-3.14).withSign(-3.14)) // -3.14
println((-3.14).withSign(0.0)) // 3.14
println(Double.NaN.withSign(-1.0)) // NaN
//sampleEnd
}Returns this value with the sign bit same as of the sign value.
Since Kotlin
1.8Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(3.14.withSign(100)) // 3.14
println(3.14.withSign(-100)) // -3.14
println((-3.14).withSign(-100)) // -3.14
println((-3.14).withSign(0)) // 3.14
println(Double.NaN.withSign(-1)) // NaN
//sampleEnd
}Returns this value with the sign bit same as of the sign value.
If sign is NaN the sign of the result is undefined.
Since Kotlin
1.8Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(3.14f.withSign(3.14f)) // 3.14
println(3.14f.withSign(-3.14f)) // -3.14
println((-3.14f).withSign(-3.14f)) // -3.14
println((-3.14f).withSign(0.0f)) // 3.14
println(Float.NaN.withSign(-1.0f)) // NaN
//sampleEnd
}Returns this value with the sign bit same as of the sign value.
Since Kotlin
1.8Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(3.14f.withSign(100)) // 3.14
println(3.14f.withSign(-100)) // -3.14
println((-3.14f).withSign(-100)) // -3.14
println((-3.14f).withSign(0)) // 3.14
println(Float.NaN.withSign(-1)) // NaN
//sampleEnd
}