---
title: vDSP.ThresholdRule.clampToThreshold
framework: accelerate
role: symbol
role_heading: Case
path: accelerate/vdsp/thresholdrule/clamptothreshold
---

# vDSP.ThresholdRule.clampToThreshold

Returns the threshold if the input value is less than threshold; otherwise returns the input value.

## Declaration

```swift
case clampToThreshold
```

## Discussion

Discussion Use vDSP.ThresholdRule.clampToThreshold to calculate a new vector where the threshold operation sets all source values below the threshold to the threshold. let source: [Float] = [12, 13, 14, 15, 16, 17, 18]

let destination = vDSP.threshold(source,                                  to: 15,                                  with: .clampToThreshold)

// Prints "[15.0, 15.0, 15.0, 15.0, 16.0, 17.0, 18.0]". print(destination)

## See Also

### Threshold rules

- [vDSP.ThresholdRule.signedConstant(_:)](accelerate/vdsp/thresholdrule/signedconstant(_:).md)
- [vDSP.ThresholdRule.zeroFill](accelerate/vdsp/thresholdrule/zerofill.md)
