aboutsummaryrefslogtreecommitdiff
path: root/src/benchmarks/cfrac/phalf.c
blob: 8658de599d03fe9d2b150c8627322e08d2f46ee5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <string.h>
#include "pdefs.h"
#include "precision.h"

#ifdef ASM_16BIT
#include "asm16bit.h"
#endif

/*
 * Divide a precision by 2 
 */
precision phalf(u)
   register precision u;
{
#ifdef ASM_16BIT
   register precision w;
   register posit usize;

   pparm(u);
   usize = u->size;
   w = palloc(usize);
   if (w == pUndef) return w;

   w->sign = u->sign;
   (void) memcpy(w->value, u->value, usize * sizeof(digit));

   memlsrw(w->value, usize);		/* 68000 assembly language routine */
   if (usize > 1 && w->value[usize-1] == (digit) 0) {	      /* normalize */
      --(w->size);
   }
   pdestroy(u);
   return presult(w);
#else
   return pdiv(u, ptwo);
#endif
}