Skip to content

Commit

Permalink
chore: clarify example for nans on numbers page
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahhaggarty committed Oct 5, 2023
1 parent 59fa61f commit 2dcd013
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion docs/topics/numbers.md
Original file line number Diff line number Diff line change
Expand Up @@ -303,10 +303,16 @@ Here is an example that shows the difference in behavior between operands static
```kotlin
fun main() {
//sampleStart
// Operand statically typed as floating-point number
println(Double.NaN == Double.NaN) // false
// Operand NOT statically typed as floating-point number
// So NaN is equal to itself
println(listOf(Double.NaN) == listOf(Double.NaN)) // true


// Operand statically typed as floating-point number
println(0.0 == -0.0) // true
// Operand NOT statically typed as floating-point number
// So -0.0 is less than 0.0
println(listOf(0.0) == listOf(-0.0)) // false

println(listOf(Double.NaN, Double.POSITIVE_INFINITY, 0.0, -0.0).sorted())
Expand Down

0 comments on commit 2dcd013

Please sign in to comment.