PropWare  3.0.0.229
C++ objects and CMake build system for Parallax Propeller
constrainFloat.c
1 /*
2  * @file constrainFloat.c
3  *
4  * @author Andy Lindsay
5  *
6  * @version 1.1.8
7  *
8  * @copyright Copyright (C) Parallax, Inc. 2018. See end of file for
9  * terms of use (MIT License).
10  *
11  * @brief constrainFloat function source, see simpletools.h for documentation.
12  *
13  * @detail Please submit bug reports, suggestions, and improvements to
14  * this code to editor@parallax.com.
15  */
16 
17 
18 
19 
20 #include "simpletools.h"
21 
22 float constrainFloat(float value, float min, float max)
23 {
24  if(min > max)
25  {
26  float temp = min;
27  min = max;
28  max = temp;
29  }
30 
31  if (value < min) value = min;
32  if (value > max) value = max;
33  return value;
34 }
35 
36 
37 
38 
simpletools.h
This library provides convenient functions for a variety of microcontroller I/O, timing,...
constrainFloat
float constrainFloat(float value, float min, float max)
Constrains a floating point value to a range from a minimum value to a maximum value....
Definition: constrainFloat.c:22