A little more efficient using modf here.