summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Core/NumericExtensions.cs
blob: fb7c78ae60aa15dfa9457b0889d8d1652c1d5785 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
using System;
using System.ComponentModel;

namespace Xamarin.Forms.Internals
{
	public static class NumericExtensions
	{

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static double Clamp(this double self, double min, double max)
		{
			return Math.Min(max, Math.Max(self, min));
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static int Clamp(this int self, int min, int max)
		{
			return Math.Min(max, Math.Max(self, min));
		}
	}
}