How about this (btw the sign in your #8 seems wrong),
class main{
public static double eps=System.Math.Pow(2,-52);
public static double wrap(double s, double L, double x){
L*=(1+eps);
return ((x-s)%L+L)%L+s;
}
public static void Main(){
double s=-5,L=10;
System.Console.WriteLine(wrap(s,L, 3.0));
System.Console.WriteLine(wrap(s,L, 6.0));
System.Console.WriteLine(wrap(s,L,-6.0));
System.Console.WriteLine(wrap(s,L, 0.0));
System.Console.WriteLine(wrap(s,L,-5.0));
System.Console.WriteLine(wrap(s,L, 5.0));
System.Console.WriteLine(wrap(s,L, 4.999999999));
System.Console.WriteLine(wrap(s,L,-5.000000001));
}
}