PetscClipInterval — PETSc 3.22.5 documentation

Skip to main content
`Ctrl`+`K`

# PetscClipInterval

Returns a number clipped to be within an interval

## Synopsis

    #include <petscmath.h>
    type clip PetscClipInterval(type x,type a,type b)

Not Collective

## Input Parameters

- x - value to use if within interval [a,b]

- a - lower end of interval

- b - upper end of interval

## Note

The type can be integer or floating point value

Example:

      PetscInt c = PetscClipInterval(5, 2, 3); // the value of c is 3
      PetscInt c = PetscClipInterval(5, 2, 6); // the value of c is 5

## See Also

`PetscMin()`, `PetscMax()`, `PetscAbsInt()`, `PetscAbsReal()`, `PetscSqr()`

## Level

beginner

## Location

include/petscmath.h

Index of all Sys routines
Table of Contents for all manual pages
Index of all manual pages