This file contains hidden or 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
| // Generates a Checksum | |
| // EXAMPLE: Input="Hello World!!" -> Output="5E" | |
| public static string GenerateChecksum(string input) | |
| { | |
| byte[] bytes = Encoding.ASCII.GetBytes(input); | |
| byte result = 0; | |
| foreach (byte c in bytes) | |
| result += c; | |
| result &= 0xff; | |
| return result.ToString("X2"); |
This file contains hidden or 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
| // Calculate PI | |
| // OUTPUT (59 seconds on my old i5 laptop): | |
| // PI = 3.14159264498239 vs 3.14159265358979 | |
| // Difference = 8.60740323460618E-09 | |
| public double CalculatePI() | |
| { | |
| double pi = 0; | |
| double sum = 1; | |
| double sqr = 0; | |
| for (double n = 2; n < 10000000000; n++) |