Floor algorithm