Created
January 2, 2025 18:33
-
-
Save jskeet/7d825e0e003c9139c3d626fcb295ffe2 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
double[] inputs = { -10.0, -6.0, -5.0, -4.0, -3.0, -2.0, -1.0, 0.0, 0.001, 1.0, 2.0, 5.0, 6.0, 10.0, 12.0, 15.0, 25.0 }; | |
foreach (var input in inputs) | |
{ | |
var output = WrapPositive(10L, input); | |
Console.WriteLine($"{input} => {output}"); | |
} | |
double WrapPositive(double periodicDistance, double position) => | |
(position % periodicDistance + periodicDistance) % periodicDistance; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment