ack/modules/src/flt_arith/b64_sft.c

49 lines
1,001 B
C
Raw Normal View History

1989-07-10 11:17:19 +00:00
/*
(c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
See the copyright notice in the ACK home directory, in the file "Copyright".
*/
1994-06-24 11:31:16 +00:00
/* $Id$ */
1989-07-10 11:17:19 +00:00
1991-02-19 13:53:04 +00:00
#include "flt_misc.h"
1989-07-10 11:17:19 +00:00
1993-10-21 12:50:58 +00:00
void
flt_b64_sft(e,n)
register struct flt_mantissa *e;
1989-07-10 11:17:19 +00:00
register int n;
{
1989-10-16 17:56:36 +00:00
if (n > 63 || n < -63) {
e->flt_l_32 = 0;
e->flt_h_32 = 0;
return;
}
if (n >= 32) {
e->flt_l_32 = e->flt_h_32;
e->flt_h_32 = 0;
n -= 32;
}
1989-07-10 11:17:19 +00:00
if (n > 0) {
1989-10-16 17:56:36 +00:00
e->flt_l_32 = (e->flt_l_32 >> 1) & 0x7FFFFFFF;
e->flt_l_32 >>= (n - 1);
if (e->flt_h_32 != 0) {
e->flt_l_32 |= (e->flt_h_32 << (32 - n)) & 0xFFFFFFFF;
e->flt_h_32 = (e->flt_h_32 >> 1) & 0x7FFFFFFF;
e->flt_h_32 >>= (n - 1);
1989-07-10 11:17:19 +00:00
}
}
n = -n;
1989-10-16 17:56:36 +00:00
if (n >= 32) {
e->flt_h_32 = e->flt_l_32;
e->flt_l_32 = 0;
n -= 32;
}
1989-07-10 11:17:19 +00:00
if (n > 0) {
1989-10-16 17:56:36 +00:00
e->flt_h_32 = (e->flt_h_32 << n) & 0xFFFFFFFF;
if (e->flt_l_32 != 0) {
long l = (e->flt_l_32 >> 1) & 0x7FFFFFFF;
e->flt_h_32 |= (l >> (31 - n));
e->flt_l_32 = (e->flt_l_32 << n) & 0xFFFFFFFF;
1989-07-10 11:17:19 +00:00
}
}
}