Example #1
0
/* Makes command separated string for possible displacement/force * types */
char *fdbFemStrSuppForcTypListInt(char *dtype)
{
  long restypes[270];
  long len = 270 ;
  long restypes_ret[270];
  long len_ret = 0 ;
  ldiv_t divval ;
  ldiv_t divval2 ;
  long type ;
  long i, j, k ;

  for (i=0; i<len; i++) 
  { 
    restypes[i] = 0 ; 
    restypes_ret[i] = 0 ; 
  }
  len_ret = 0 ;


  for (i=0; i<len; i++)
  {
    restypes[i] = 0 ;

    for (j=0; j<fdbInputTabLenAll(ETYPE); j++ ) /* type=0 is not used */
    {
      type = fdbInputGetInt(ETYPE,ETYPE_TYPE, j) ;
      if ((type<=0) || (type >=fdbElementTypeLen)) { break ; }
      
      for (k=0; k<fdbElementType[type].ndofs; k++)
      {
        divval  = ldiv(i+1,KNOWN_DOFS);
        divval2 = ldiv(fdbElementType[type].ndof[k],KNOWN_DOFS);

        if (
            (divval.rem == fdbElementType[type].ndof[k])
          ||
          ((divval2.quot >= 1) && (divval2.rem == 0) && (divval.rem == 0))
           )
        {
          restypes[i] = 1 ;
          break ;
        }
      }
      if (restypes[i] == 1) {break;}
    }
  }

  for (i=0; i<len; i++)
  {
    if (restypes[i] == 1)
    {
      restypes_ret[len_ret] = (i+1) ;
      len_ret++ ;
    }
  }

  if (len_ret < 1) { return(" ") ; } 

  return(ciListVarsListedCSV(dtype, restypes_ret, len_ret)) ;
}
Example #2
0
char* sec2str(unsigned long seconds) {
	unsigned long h, m, s;
	char hh[3], mm[3], ss[3], *str;
	ldiv_t res;

	res = ldiv(seconds, 3600);
	h = res.quot;
	res = ldiv(res.rem, 60);
	m = res.quot;
	s = res.rem;

	sprintf(hh, "%02lu", h);
	sprintf(mm, "%02lu", m);
	sprintf(ss, "%02lu", s);

	str = (char *) malloc(9 * sizeof(char));
	str[0] = '\0';
	strcat(str, hh);
	strcat(str, ":");
	strcat(str, mm);
	strcat(str, ":");
	strcat(str, ss);

	return str;
}
Example #3
0
CTile* CMainMap::getTileFromScreen(long xScreen, long yScreen) {
	
	CTile* retTile = NULL;
	long tx, ty;

	if (xScreen >= 0 && yScreen >= 0) {
		
		ldiv_t ldivresult;

		ldivresult = ldiv(xScreen+1, m_tileWidth);
		tx = ldivresult.quot;

		ldivresult = ldiv(yScreen+1, m_tileHeight);
		ty = ldivresult.quot;

		ostringstream ostr;
		ostr << "\ntx: " << tx << ", ty: " << ty << "\n";
		fprintf(stderr, ostr.str().c_str());

		retTile = getTileFromMap(tx, ty);
	}
	else {
		fprintf(stderr, "DataErr: CTile::getTile - x or y value <0!!\n");
	}

	return retTile;
}
Example #4
0
void print_time( long int ticks )
  {
    ldiv_t sec_ticks;
    ldiv_t min_sec;

    sec_ticks = ldiv( ticks, 100L );
    min_sec   = ldiv( sec_ticks.quot, 60L );
    printf( "It took %ld minutes and %ld seconds\n",
             min_sec.quot, min_sec.rem );
  }
Example #5
0
// Function that snaps a point to a grid
CPoint SnapToGrid(CPoint point) {
	CPoint ret;

	ldiv_t blob = ldiv(point.x,GRIDSIZE);
	ret.x = blob.quot*GRIDSIZE;
	blob = ldiv(point.y,GRIDSIZE);
	ret.y = blob.quot*GRIDSIZE;

	return ret;
}
Example #6
0
/**
 * Returns 1 (true) if the specified number is a prime number, 0 (false)
 * otherwise.
 */
int is_prime(unsigned long num)
{
    unsigned int *sieve;
    char num_bit;
    unsigned long start_pos, i, ptr_size;
    ldiv_t qr;

    /* Edge cases */
    if ((num == 0) || (num == 1)) return 0;

    /* The sieve we'll use to determine if num is a prime or not. */
    sieve = new_sieve(num);
    ptr_size = sizeof(sieve[0])*CHAR_BIT;

    /* sieve[2] represents the number 2. We only have to find multiples/factors up to sqrt(num). */
    for (start_pos = 2; start_pos <= (unsigned long)sqrt(num); ++start_pos)
    {
        /* If this number is cleared, then so will all of its multiples, in which
           case there is nothing needed to be done. */
        qr = ldiv(start_pos, ptr_size);
        if (( sieve[qr.quot] & (1 << qr.rem) ) != 0) {
            /* Clear all numbers that are multiples of 'sieve[start_pos]' */
            for (i = start_pos; i <= num; i = i + start_pos)
            {
                qr = ldiv(i, ptr_size);
                sieve[qr.quot] &= ~(1 << qr.rem);

                if (i == num)
                {
                    /* We've cleared 'sieve[num]' we now know it's not a prime number */
                    break;
                }
            }

            if (i == num)
            {
                printf("Divisible by %lu\n", start_pos);
                /* We've cleared 'sieve[num]' we now know it's not a prime number */
                break;
            }
        }
    }

    /* Get the value of the bit at position 'num' */
    qr = ldiv(num, ptr_size);
    num_bit = ( sieve[qr.quot] & (1 << qr.rem) ) != 0;

    free(sieve);

    // 'num' is a prime if the bit 'sieve[num]' was still set.
    return num_bit;
}
Example #7
0
int main( void )
{
    ldiv_t result;
    result = ldiv( 5, 2 );
    TESTCASE( result.quot == 2 && result.rem == 1 );
    result = ldiv( -5, 2 );
    TESTCASE( result.quot == -2 && result.rem == -1 );
    result = ldiv( 5, -2 );
    TESTCASE( result.quot == -2 && result.rem == 1 );
    TESTCASE( sizeof( result.quot ) == _PDCLIB_LONG_BYTES );
    TESTCASE( sizeof( result.rem )  == _PDCLIB_LONG_BYTES );
    return TEST_RESULTS;
}
Example #8
0
int main( void )
{
    ldiv_t result;
    result = ldiv( 5, 2 );
    TESTCASE( result.quot == 2 && result.rem == 1 );
    result = ldiv( -5, 2 );
    TESTCASE( result.quot == -2 && result.rem == -1 );
    result = ldiv( 5, -2 );
    TESTCASE( result.quot == -2 && result.rem == 1 );
    TESTCASE( sizeof( result.quot ) == sizeof( long ) );
    TESTCASE( sizeof( result.rem )  == sizeof( long ) );
    return TEST_RESULTS;
}
Example #9
0
static void RadCalc_EVENT(void) {
	if (!Timer_1s) {								// Every 1s (1Hz)
		Timer_1s = 1000;

		if ( _FLAG.LCDExist == _Set ) lcd_ctrl(_FLAG.LCDControl);

		static uint16_t table[Ilosc_pomiarow];
		static uint8_t index;
		uint32_t sr1=0;
		ldiv_t result;

		table[index++] = pulse_counter;
		pulse_counter=0;
		if ( index >= Ilosc_pomiarow ) index=0;

		for (uint8_t i=0;i<Ilosc_pomiarow;i++) sr1 += table[i];

		result = ldiv(sr1,100);

		sprintf(SecondLine, " %lu.%02lu uSv/h", result.quot, result.rem);

		uart_putnum(sr1,10);
		uart_putstr("\r\n");
	}
}
Example #10
0
/****************************************************************************
   function: periods_elapsed()

 parameters:     bdate - beginning date
	     curr_date - ending date
	      inc_days - the period size in days

    returns: The number of periods elapsed between two dates as an integer.

    purpose: This function will calculate the number of periods between
	     any to dates.
****************************************************************************/
long periods_elapsed(char *b_date, char *e_date, long inc_days)
  {
  ldiv_t q_r;

  q_r = ldiv(days_elapsed(b_date, e_date), inc_days);
  return(q_r.quot);
  }
Example #11
0
static void gid_location(long gid, long *cylID, long *ringID)
{
  ldiv_t result;
  result = ldiv(gid, cylSize);
  *cylID = result.quot;  /* cylinder ID */
  *ringID = result.rem;  /* ring ID */
}
Example #12
0
emstream& operator<< (emstream& serial, time_stamp& stamp)
{
	char dig_buffer[7];						// Holds digits we compute
	ldiv_t div_result;						// Holds results of long integer division

	// First write the seconds in the time stamp, then a decimal
	serial << stamp.get_seconds ();
	serial.putchar ('.');

	// Now get the microseconds; these will be written with leading zeros as needed
	div_result.quot = stamp.get_microsec ();
	for (int8_t index = 5; index >= 0; index--)
	{
		div_result = ldiv (div_result.quot, 10);
		dig_buffer[index] = div_result.rem + '0';
	}

	// The last item in the string must be a '\0' null character
	dig_buffer[6] = '\0';

	// Write the buffer, which now contains microsecond digits
	serial << dig_buffer;

	return (serial);
}
Example #13
0
/** Start the cpu timer (before running a command).
 */
void
start_cpu_timer(void)
{
#ifndef PROFILING
  cpu_time_limit_hit = 0;
  cpu_limit_warning_sent = 0;
  timer_set = 1;
#if defined(HAS_ITIMER)         /* UNIX way */
  {
    struct itimerval time_limit;
    if (options.queue_entry_cpu_time > 0) {
      ldiv_t t;
      /* Convert from milliseconds */
      t = ldiv(options.queue_entry_cpu_time, 1000);
      time_limit.it_value.tv_sec = t.quot;
      time_limit.it_value.tv_usec = t.rem * 1000;
      time_limit.it_interval.tv_sec = 0;
      time_limit.it_interval.tv_usec = 0;
      if (setitimer(ITIMER_PROF, &time_limit, NULL)) {
        perror("setitimer");
        timer_set = 0;
      }
    } else
      timer_set = 0;
  }
#elif defined(WIN32)            /* Windoze way */
  if (options.queue_entry_cpu_time > 0)
    timer_id = SetTimer(NULL, 0, (unsigned) options.queue_entry_cpu_time,
                        (TIMERPROC) win32_timer);
  else
    timer_set = 0;
#endif
#endif
}
Example #14
0
static void wait_timeout(struct timespec *timeout, int ms)
{
	ldiv_t div_result;
	long sec, usec, x;

#ifdef WIN32
	{
		struct _timeb now;
		_ftime(&now);
		sec = now.time;
		usec = now.millitm * 1000; /* microsecond precision would be better */
	}
#else
	{
		struct timeval now;
		gettimeofday(&now, NULL);
		sec = now.tv_sec;
		usec = now.tv_usec;
	}
#endif

	/* add current time + millisecond offset */
	div_result = ldiv(ms, 1000);
	timeout->tv_sec = sec + div_result.quot;

	x = usec + (div_result.rem * 1000);

	if (x >= 1000000) {
		timeout->tv_sec++;
		x -= 1000000;
	}

	timeout->tv_nsec = x * 1000;
}
Example #15
0
char *                  /* addr of terminating null */
ltostr (
    char *str,          /* output string */
    long val,           /* value to be converted */
    unsigned base)      /* conversion base       */
{
    ldiv_t r;           /* result of val / base */

    if (base > 36)      /* no conversion if wrong base */
    {
        str = '\0';
        return str;
    }
    if (val < 0)    *str++ = '-';
    r = ldiv (labs(val), base);

    /* output digits of val/base first */

    if (r.quot > 0)  str = ltostr (str, r.quot, base);

    /* output last digit */

    *str++ = "0123456789abcdefghijklmnopqrstuvwxyz"[(int)r.rem];
    *str   = '\0';
    return str;
}
Example #16
0
char *ltoa(long N, char *str, int base)
{
      register int i = 2;
      long uarg;
      char *tail, *head = str, buf[BUFSIZE];

      if (36 < base || 2 > base)
            base = 10;                    /* can only use 0-9, A-Z        */
      tail = &buf[BUFSIZE - 1];           /* last character position      */
      *tail-- = '\0';

      if (10 == base && N < 0L)
      {
            *head++ = '-';
            uarg    = -N;
      }
      else  uarg = N;

      if (uarg)
      {
            for (i = 1; uarg; ++i)
            {
                  register ldiv_t r;

                  r       = ldiv(uarg, base);
                  *tail-- = (char)(r.rem + ((9L < r.rem) ?
                                  ('A' - 10L) : '0'));
                  uarg    = r.quot;
            }
      }
      else  *tail-- = '0';

      memcpy(head, ++tail, i);
      return str;
}
Example #17
0
// читать из порта
int port_read ( const askue_port_t *Port, uint8_array_t *u8a, long int timeout )
{
    ldiv_t Sec = ldiv ( timeout, 1000 );
    struct timeval Timeout = { Sec.quot, Sec.rem * 1000 };
    
    fd_set ReadSet;
    FD_ZERO ( &ReadSet );
    FD_SET ( Port->RS232, &ReadSet );

    int RetVal = select( Port->RS232 + 1, &ReadSet, NULL, NULL, &Timeout);
    
    if ( RetVal == 0 )
    {
        return 0;
    }
    else if ( RetVal == -1 )
    {
        return -1;
    }
    else
    {
        assert ( FD_ISSET ( Port->RS232, &ReadSet ) );
        return __port_read ( Port, u8a );
    }
}
Example #18
0
/*
 * general fractional timestamp formatting
 *
 * Many pieces of ntpd require a machine with two's complement
 * representation of signed integers, so we don't go through the whole
 * rigamarole of creating fully portable code here. But we have to stay
 * away from signed integer overflow, as this might cause trouble even
 * with two's complement representation.
 */
const char *
format_time_fraction(
	time_t	secs,
	long	frac,
	int	prec
	)
{
	char *		cp;
	u_int		prec_u;
	u_time		secs_u;
	u_int		u;
	long		fraclimit;
	int		notneg;	/* flag for non-negative value	*/
	ldiv_t		qr;

	DEBUG_REQUIRE(prec != 0);

	LIB_GETBUF(cp);
	secs_u = (u_time)secs;
	
	/* check if we need signed or unsigned mode */
	notneg = (prec < 0);
	prec_u = abs(prec);
	/* fraclimit = (long)pow(10, prec_u); */
	for (fraclimit = 10, u = 1; u < prec_u; u++) {
		DEBUG_INSIST(fraclimit < fraclimit * 10);
		fraclimit *= 10;
	}

	/*
	 * Since conversion to string uses lots of divisions anyway,
	 * there's no big extra penalty for normalisation. We do it for
	 * consistency.
	 */
	if (frac < 0 || frac >= fraclimit) {
		qr = ldiv(frac, fraclimit);
		if (qr.rem < 0) {
			qr.quot--;
			qr.rem += fraclimit;
		}
		secs_u += (time_t)qr.quot;
		frac = qr.rem;
	}

	/* Get the absolute value of the split representation time. */
	notneg = notneg || ((time_t)secs_u >= 0);
	if (!notneg) {
		secs_u = ~secs_u;
		if (0 == frac)
			secs_u++;
		else
			frac = fraclimit - frac;
	}

	/* finally format the data and return the result */
	snprintf(cp, LIB_BUFLENGTH, "%s%" UTIME_FORMAT ".%0*ld",
	    notneg? "" : "-", secs_u, prec_u, frac);
	
	return cp;
}
Example #19
0
void factors( unsigned long x) {

    unsigned long i;
    unsigned long max_factor;
    unsigned long current_factor;
    ldiv_t results;

    /* set the max_factor to square root of variable */
    max_factor = sqrt(x)+1;

    /* see if the variable is more than MAXSIZE^2 */
    if ( max_factor > MAXSIZE ) {
        printf ("Too large to solve, the largest number I can factor is %d.", MAXSIZE);
        exit (1);
    }
    printf ("%d: ", x);
    
    /* while current_factor < max_factor */
    for(i=2; i<max_factor; i++, i++) {

        /* Test factor */
        results = ldiv(x, i);
    
        /* If there is no remainder, print the current_factor, continue. */
        if ( results.rem == 0 ) {
            printf ("%d ", i);
            x = results.quot;
            max_factor = sqrt(x)+1 ;
            i--; i--;
        }
        if (i==2) i=1;
    }
    printf ("%d\n", x);
}
Example #20
0
 static DWORD HashKey(KeyT Key)
 {
     ldiv_t hash_val = ldiv((long)Key, 127773);
     hash_val.rem = 16807 * hash_val.rem - 2836 * hash_val.quot;
     if (hash_val.rem < 0) hash_val.rem += 2147483647;
     return ((DWORD)hash_val.rem);
 }
Example #21
0
char *
int2str(register long int val, register char *dst, register int radix, 
        int upcase)
{
  char buffer[65];
  register char *p;
  long int new_val;
  char *dig_vec= upcase ? _dig_vec_upper : _dig_vec_lower;

  if (radix < 0)
  {
    if (radix < -36 || radix > -2)
      return NullS;
    if (val < 0)
    {
      *dst++ = '-';
      val = -val;
    }
    radix = -radix;
  }
  else if (radix > 36 || radix < 2)
    return NullS;

  /*
    The slightly contorted code which follows is due to the fact that
    few machines directly support unsigned long / and %.  Certainly
    the VAX C compiler generates a subroutine call.  In the interests
    of efficiency (hollow laugh) I let this happen for the first digit
    only; after that "val" will be in range so that signed integer
    division will do.  Sorry 'bout that.  CHECK THE CODE PRODUCED BY
    YOUR C COMPILER.  The first % and / should be unsigned, the second
    % and / signed, but C compilers tend to be extraordinarily
    sensitive to minor details of style.  This works on a VAX, that's
    all I claim for it.
  */
  p = &buffer[sizeof(buffer)-1];
  *p = '\0';
  new_val=(ulong) val / (ulong) radix;
  *--p = dig_vec[(uchar) ((ulong) val- (ulong) new_val*(ulong) radix)];
  val = new_val;
#ifdef HAVE_LDIV
  while (val != 0)
  {
    ldiv_t res;
    res=ldiv(val,radix);
    *--p = dig_vec[res.rem];
    val= res.quot;
  }
#else
  while (val != 0)
  {
    new_val=val/radix;
    *--p = dig_vec[(uchar) (val-new_val*radix)];
    val= new_val;
  }
#endif
  while ((*dst++ = *p++) != 0) ;
  return dst-1;
}
Example #22
0
File: root.c Project: Hooman3/minix
/*
 * Print load averages.
 */
static void
root_loadavg(void)
{
	struct load loads[3];
	ldiv_t avg[3];

	if (procfs_getloadavg(loads, 3) != 3)
		return;

	avg[0] = ldiv(100L * loads[0].proc_load / loads[0].ticks, 100);
	avg[1] = ldiv(100L * loads[1].proc_load / loads[1].ticks, 100);
	avg[2] = ldiv(100L * loads[2].proc_load / loads[2].ticks, 100);

	buf_printf("%ld.%02ld %ld.%02ld %ld.%02ld\n",
	    avg[0].quot, avg[0].rem, avg[1].quot, avg[1].rem,
	    avg[2].quot, avg[2].rem);
}
Example #23
0
static void output_vertices (vertex_db & vertices)
{
    std::string tmp_file_name = "tmpidmap";
    boost::shared_ptr<SpatialIndex::IStorageManager>
        tmp_file (SpatialIndex::StorageManager::createNewDiskStorageManager (
                      tmp_file_name,page_size));
    idmap_t idmap (tmp_file, page_size);

    vertex_db::iterator v_start = vertices.begin ();
    vertex_db::iterator v_ptr = v_start;

    ofstream myfile;
    myfile.open ("example.txt");

    long v_id = 1;
    long edges = 0;
//    map<vertex_id,long> idmap;

    while (v_ptr != vertices.end ())
    {
        edges += ((vertex_info)v_ptr->second).neighbours.size ();

//	idmap.insert(pair<vertex_id,long>((vertex_id)v_ptr->first,v_id));
        idmap.insert (v_ptr->first, v_id);
	v_id++;
        v_ptr++;
    }
   
    v_id--; 
    ldiv_t divresult = ldiv(edges,2);
    myfile << v_id << " " << divresult.quot << " 0\n";

    v_start = vertices.begin ();
    v_ptr = v_start;
    v_id = 1;
  
    while (v_ptr != vertices.end ())
    {
        std::vector<vertex_id> n = ((vertex_info)v_ptr->second).neighbours;
        vertex_id id = (vertex_id)v_ptr->first;

//                map<vertex_id,long>::iterator it;

//        it = idmap.find(id);
        std::cout << get_remapped_vertex (idmap, id) << " : ";
        //std::cout << it->second << " : ";

        BOOST_FOREACH (vertex_id n_id, n)
        {
//                it = idmap.find(n_id);
                myfile << get_remapped_vertex (idmap, n_id) << " ";
        }

        myfile << endl;

        v_id++;
        v_ptr++;
    }
Example #24
0
extern massgd_sample_addr * WPGetMassgdSampData( sio_data * curr_sio,
        clicks_t click_index )
/*********************************************************************/
{
    ldiv_t              ans;

    if( click_index >= curr_sio->number_massaged ) return( NULL );
    ans = ldiv( click_index, MAX_MASSGD_BUCKET_INDEX );
    return( &curr_sio->massaged_sample[ans.quot][ans.rem] );
}
Example #25
0
void stdlib_test(){
	ldiv_t ans;
	long N = 15;
	long D = 4;
	ans = ldiv(N,D);
	printf("%ld %ld",ans.quot,ans.rem);



}
Example #26
0
uint64_t sum_square_digits(uint64_t x) {
  uint64_t sum = 0;

  while(x > 0) {
    ldiv_t div_result = ldiv(x, 10);
    sum += div_result.rem * div_result.rem;
    x = div_result.quot;
  }

  return sum;
}
Example #27
0
void CompletionPercentage::stepWithNMultipleOf100() {
  currentIteration_ += 1;
  currentDiv_ = ldiv(currentIteration_, totalDiv_.quot);

  if (currentDiv_.rem==0) {
    currentOutput_ = boost::lexical_cast<std::string>(currentDiv_.quot) + "%";
    logTee << std::string(precedingOutput_.length(),'\b') << currentOutput_;
    logTee.flush();
    precedingOutput_ = currentOutput_;
  }
}
Example #28
0
File: root.c Project: Hooman3/minix
/*
 * Print the current uptime.
 */
static void
root_uptime(void)
{
	clock_t ticks;
	ldiv_t division;

	if (getticks(&ticks) != OK)
		return;
	division = ldiv(100L * ticks / sys_hz(), 100L);

	buf_printf("%ld.%0.2ld\n", division.quot, division.rem);
}
/* ----------------------------------------------
 * bundles_needed
 * ---------------------------------------------- */
long bundles_needed (long data, long pl)
{
    long res = 0;
    ldiv_t r;

    r = ldiv(data, pl);
    res = r.quot;
    if (r.rem > 0)
        res += 1;

    return res;
} // end bundles_needed
Example #30
0
/*  calc_target()
 */
static void calc_target(garray_t *ga, int64_t gidx, int64_t *tnid_, int64_t *tidx_)
{
    /* if this node has no local elements, there are less than nnodes
       elements, so the array index is the node index */
    if (ga->nlocal_elems == 0) {
        *tnid_ = gidx;
        *tidx_ = 0;
        return;
    }

    /* compute the target nid+idx */
    ldiv_t res = ldiv(gidx, ga->nlocal_elems);

    /* if the distribution is not perfectly even, we have to adjust
       the target nid+idx appropriately */
    if (ga->nextra_elems > 0) {
        int64_t tnid = res.quot, tidx = res.rem;

        /* if i have an extra element... */
        if (ga->g->nid < ga->nextra_elems) {
            /* but the target does not */
            if (tnid >= ga->nextra_elems) {
                /* then the target index has to be adjusted upwards */
                tidx += (tnid - ga->nextra_elems);
                /* which may mean that the target nid does too */
                while (tidx >= (ga->nlocal_elems - 1)) {
                    ++tnid;
                    tidx -= (ga->nlocal_elems - 1);
                }
            }
        }

        /* i don't have an extra element... */
        else {
            /* so adjust the target index downwards */
            tidx -= (tnid < ga->nextra_elems ? tnid : ga->nextra_elems);
            /* which may mean the target nid has to be adjusted too */
            while (tidx < 0) {
                --tnid;
                tidx += ga->nelems_per_node + (tnid < ga->nextra_elems ? 1 : 0);
            }
        }

        res.quot = tnid; res.rem = tidx;
    }

    LOG_DEBUG(ga->g->glog, "[%d] garray calc %ld, target %ld.%ld\n",
              ga->g->nid, gidx, res.quot, res.rem);

    *tnid_ = res.quot;
    *tidx_ = res.rem;
}