Groups | Search | Server Info | Login | Register


Groups > comp.arch.arithmetic > #77

Re: New appromixation for integer division by 63 or 127

X-Received by 10.43.69.18 with SMTP id ya18mr3012547icb.0.1413032759785; Sat, 11 Oct 2014 06:05:59 -0700 (PDT)
X-Received by 10.140.94.10 with SMTP id f10mr18581qge.11.1413032759644; Sat, 11 Oct 2014 06:05:59 -0700 (PDT)
Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!h18no4621282igc.0!news-out.google.com!i10ni82qaf.0!nntp.google.com!dc16no2072290qab.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups comp.arch.arithmetic
Date Sat, 11 Oct 2014 06:05:59 -0700 (PDT)
In-Reply-To <74d951ee-6fd2-43ad-8f0a-2852a031bd2c@googlegroups.com>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=5.55.57.237; posting-account=lD5X3AoAAAB2_KDReA0WuoP_A_fBgycC
NNTP-Posting-Host 5.55.57.237
References <74d951ee-6fd2-43ad-8f0a-2852a031bd2c@googlegroups.com>
User-Agent G2/1.0
MIME-Version 1.0
Message-ID <af2217af-30fe-42e2-bc0d-1a9bf6847c35@googlegroups.com> (permalink)
Subject Re: New appromixation for integer division by 63 or 127
From nikolaos.kavvadias@gmail.com
Injection-Date Sat, 11 Oct 2014 13:05:59 +0000
Content-Type text/plain; charset=ISO-8859-1
Xref csiph.com comp.arch.arithmetic:77

Show key headers only | View raw


I have updated my claims for the algorithm. It works for all tested constant divisors (n=2 to n=16), and given the following assumption:

the range for x is [0,2^(2*n)-2], i.e. for n = 6, the range indeed is 
0:4094. 

And a test program: 

[code] 
#include <stdio.h> 
#include <stdlib.h> 
#include <math.h> 

/* main: 
 */ 
int main(void) 
{ 
  int qapprox, qexact; 
  int i, j, k; 

  for (i = 2; i < 8; i++) { 
    for (j = 1; j < (1<<i)*(1<<i)-1; j++) { 
      k = (1<<i) - 1; 
      qapprox = (((j>>i)+j+((1<<i)+1))>>i)-1; 
      qexact  = j / k; 
      if (qapprox != qexact) { 
        fprintf(stderr, "qapprox = (%d/%d) = %d\tqexact = (%d/%d) = %d\n", 
          j, k, qapprox, j, k, qexact); 
      } 
    } 
  } 
  return 0; 
} 
[/code]

Back to comp.arch.arithmetic | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

New appromixation for integer division by 63 or 127 nikolaos.kavvadias@gmail.com - 2014-10-11 00:19 -0700
  Re: New appromixation for integer division by 63 or 127 nikolaos.kavvadias@gmail.com - 2014-10-11 06:05 -0700
  Re: New appromixation for integer division by 63 or 127 Terje Mathisen <terje.mathisen@tmsw.no> - 2014-10-13 10:20 +0200
    Re: New appromixation for integer division by 63 or 127 nikolaos.kavvadias@gmail.com - 2014-10-15 01:09 -0700

csiph-web