use even faster fmod alternative (ported back from mapnik after testing there)