What do I call a method that does this ...?

I have a method that gets two endpoints of a range - the beginning of the range and the end of the range and an integer.

It checks to see if an integer falls between two endpoints and returns either an integer or the corresponding endpoint if the integer is out of bounds.

Example 1:

  • RangeStart = 0; RangeEnd = 10; Value = 5; Returns 5

Example 2:

  • RangeStart = 0; RangeEnd = 10; Value = -4; Returns 0

Example 3:

  • RangeStart = 0; RangeEnd = 10; Value = 23; Returns 10

Question: What should I call the method that does this? I called it IntWithinRange, but I don't think I like it.

Any ideas?

+5
source share
8 answers

ConstrictToRange/LimitToRange/ConfineToRange? - , , .

+11
confine_to(start, end, value)
+7
source

GetBoundedValue?

+1
source

normalize

+1
source

Short: Squeeze().

+1
source

BoundedValue () or GetBoundedValue ()

Some of the other names sound to me as if you are changing something.

0
source

CheckRange seems to me enough

-2
source

All Articles