/**
  * generation of a position, logoot algorithm
  * @param <Object> $start is the previous logootPosition
  * @param <Object> $end is the next logootPosition
  * @param <Integer> $N number of positions generated (should be 1 in our case)
  * @param <Object> $sid session id
  * @return <Object> a logootPosition between $start and $end
  */
 private function getLogootPosition($start, $end, $N, $sid)
 {
     $result = array();
     $Id_Max = LogootId::IdMax();
     $Id_Min = LogootId::IdMin();
     $i = 0;
     $pos = array();
     $currentPosition = new LogootPosition($pos);
     // voir constructeur
     $inf = new Math_BigInteger("0");
     $sup = new Math_BigInteger("0");
     $isInf = false;
     while (true) {
         $inf = new Math_BigInteger($start->get($i)->getInt());
         if ($isInf == true) {
             $sup = new Math_BigInteger(INT_MAX);
         } else {
             $sup = new Math_BigInteger($end->get($i)->getInt());
         }
         $tmpVal = $sup->subtract($inf);
         $tmpVal1 = $tmpVal->subtract(new Math_BigInteger("1"));
         if ($tmpVal1->compare($N) > 0) {
             //				inf = start.get(i).getInteger();
             //				sup = end.get(i).getInteger();
             break;
         }
         $currentPosition->add($start->get($i));
         $i++;
         if ($i == $start->size()) {
             $start->add($Id_Min);
         }
         if ($i == $end->size()) {
             $end->add($Id_Max);
         }
         if ($inf->compare($sup) < 0) {
             $isInf = true;
         }
     }
     $binf = $inf->add(new Math_BigInteger("1"));
     $bsup = $sup->subtract(new Math_BigInteger("1"));
     $slot = $bsup->subtract($binf);
     $stepTmp = $slot->divide($N);
     $step = $stepTmp[0];
     // quotient, [1] is the remainder
     $old = clone $currentPosition;
     if ($step->compare(new Math_BigInteger(INT_MAX)) > 0) {
         $lstep = new Math_BigInteger(INT_MAX);
         $r = clone $currentPosition;
         $tmpVal2 = $inf->random($inf, $sup);
         $r->set($i, $tmpVal2->toString(), $sid);
         $result[] = $r;
         // result est une arraylist<Position>
         return $result;
     } else {
         $lstep = $step;
     }
     if ($lstep->compare(new Math_BigInteger("0")) == 0) {
         $lstep = new Math_BigInteger("1");
     }
     $p = clone $currentPosition;
     $p->set($i, $inf->toString(), $sid);
     $tmpVal3 = (int) $N->toString();
     for ($j = 0; $j < $tmpVal3; $j++) {
         $r = clone $p;
         if (!($lstep->compare(new Math_BigInteger("1")) == 0)) {
             $tmpVal4 = new Math_BigInteger($p->get($i)->getInt());
             $tmpVal5 = $tmpVal4->add($lstep);
             // max
             $tmpVal6 = new Math_BigInteger($p->get($i)->getInt());
             // min
             $add = $tmpVal6->random($tmpVal6, $tmpVal5);
             $r->set($i, $add->toString(), $sid);
         } else {
             $r->add1($i, new Math_BigInteger("1"), $sid);
         }
         $result[] = clone $r;
         // voir
         $old = clone $r;
         $tmpVal7 = new Math_BigInteger($p->get($i)->getInt());
         $tmpVal7 = $tmpVal7->add($lstep);
         $p->set($i, $tmpVal7->toString(), $sid);
     }
     return $result;
 }