<!--
{
  "availability" : [
    "iOS: 10.0.0 -",
    "iPadOS: 10.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.12.0 -",
    "tvOS: 10.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "GameplayKit",
  "identifier" : "/documentation/GameplayKit/GKNoise/clamp(lowerBound:upperBound:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "GameplayKit"
    ],
    "preciseIdentifier" : "c:objc(cs)GKNoise(im)clampWithLowerBound:upperBound:"
  },
  "title" : "clamp(lowerBound:upperBound:)"
}
-->

# clamp(lowerBound:upperBound:)

Replaces values in the noise field outside the specified range with the values at the endpoints of that range.

```
func clamp(lowerBound: Double, upperBound: Double)
```

## Parameters

`lowerBound`

The minimum value to keep in processed noise.

`upperBound`

The maximum value to keep in processed noise.

## Discussion

For example, if you specify lower and upper bounds of `-0.5` and `0.5`, this operation replaces values less than `-0.5` with `-0.5` and values greater than `0.5` with `0.5`.

![](images/com.apple.gameplaykit/media-2556384@2x.png)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)