Created
October 26, 2016 08:17
-
-
Save skjalgsm/2401e5aef1b648155c5c9bb03427a43e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static public int Max(int a, int b) { | |
a -= b; | |
a &= (~a) >> 31; | |
return a + b; | |
} | |
static public int Min(int a, int b) { | |
a -= b; | |
a &= a >> 31; | |
return a + b; | |
} | |
static public uint Clamp01(int n) { | |
return Max(Min(n, 1), 0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment