> ## Documentation Index
> Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Kotlin Greater Than Or Equal To

The `>=` (greater-than-or-equal-to) operator is a relational operator used to evaluate the structural or numerical order of two operands. In Kotlin, relational operators are not strictly primitive operations; rather, `>=` acts as syntactic sugar that delegates to the `compareTo` method, which is typically provided by implementing the `Comparable<T>` interface.

When the Kotlin compiler encounters the `>=` operator, it translates the expression into a method call that evaluates the integer result of `compareTo` against zero.

```kotlin theme={"dark"}
// Operator syntax
val result = a >= b

// Desugared equivalent
val result = a.compareTo(b) >= 0
```

## The `compareTo` Contract

For the `>=` operator to function on a given type, the left-hand operand (the receiver) must possess a `compareTo` function that accepts the right-hand operand's type and returns an `Int`. The returned integer dictates the relational outcome:

* **Positive (`> 0`):** The left operand is greater than the right.
* **Zero (`== 0`):** Both operands are equal in order.
* **Negative (`< 0`):** The left operand is less than the right.

The `>=` operator evaluates to `true` if the underlying `compareTo` call yields a positive integer or zero.

## Operator Overloading

To enable the `>=` operator for custom classes, the class must either implement the `Comparable<T>` interface or define a custom `compareTo` function explicitly marked with the `operator` keyword.

```kotlin theme={"dark"}
class CustomValue(val magnitude: Int) : Comparable<CustomValue> {
    // The 'operator' modifier is implicitly applied via the Comparable interface
    override fun compareTo(other: CustomValue): Int {
        return this.magnitude.compareTo(other.magnitude)
    }
}

// Alternatively, as a standalone operator function without the interface:
class AnotherValue(val magnitude: Int) {
    operator fun compareTo(other: AnotherValue): Int {
        return this.magnitude.compareTo(other.magnitude)
    }
}
```

## Type Resolution and Nullability

* **Type Safety:** The Kotlin compiler enforces type safety during the desugaring process. The type of the right-hand operand must be compatible with the parameter type expected by the left-hand operand's `compareTo` function.
* **Nullability:** The `>=` operator cannot be used directly on nullable types (`T?`) because the standard library `Comparable` interface requires non-null receivers and parameters. Attempting to use `>=` on a nullable type results in a compilation error unless a custom extension function (e.g., `operator fun T?.compareTo(other: T?): Int`) is explicitly defined in the scope.
* **Floating-Point Behavior:** When used with statically typed `Float` or `Double` primitives, the `>=` operator adheres strictly to IEEE 754 standards (e.g., `NaN >= NaN` evaluates to `false`). However, if the operands are boxed and compared generically via `Comparable<Float>` or `Comparable<Double>`, the comparison falls back to total order behavior, where `NaN` is considered equal to itself and greater than `POSITIVE_INFINITY`.

<div
  style={{ 
display: "flex", 
justifyContent: "space-between", 
alignItems: "center", 
maxWidth: "754px", 
padding: "1rem 0",
marginBottom: "24px"
}}
>
  <span style={{ fontWeight: "bold", fontSize: "1.25rem", color: "var(--tw-prose-headings)", fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif" }}>Tired of Poor Kotlin Skills? Fix That With Deep Grasping!</span>

  <a
    href="https://syntblaze.com"
    target="_blank"
    style={{ 
  marginLeft: "24px",
  textDecoration: "none", 
  backgroundColor: "#007AFF",
  color: "#ffffff", 
  padding: "6px 16px", 
  borderRadius: "16px",
  fontSize: "0.9rem",
  fontWeight: "600",
  textAlign: "center",
  transition: "background-color 0.2s ease"
}}
  >
    Learn More
  </a>
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/skill-tracking.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=b9b0305c93bb501c9e767b5c76c88835" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/skill-tracking.png" />

  <img src="https://mintcdn.com/syntblazellc/23tyuOzaWS88qFlc/images/nuggets.png?fit=max&auto=format&n=23tyuOzaWS88qFlc&q=85&s=c86c80197299762989e9b882419b2109" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/nuggets.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/bite-sized-exercises.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=a65f9a38c37ff28ab73ed783c53c60e3" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/bite-sized-exercises.png" />
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap", marginTop: "12px" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/mastery-chain.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=748a1763454713e679260fbb95f154a2" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/mastery-chain.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-previews.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=242f61448ff5dd6deaaab2dccc13b507" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-previews.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-explanations.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=cf0fc1c31f9cd0fc26716781be05fbc9" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-explanations.png" />
</div>
