b64_sft.c 1001 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
  3. See the copyright notice in the ACK home directory, in the file "Copyright".
  4. */
  5. /* $Id$ */
  6. #include "flt_misc.h"
  7. void
  8. flt_b64_sft(e,n)
  9. register struct flt_mantissa *e;
  10. register int n;
  11. {
  12. if (n > 63 || n < -63) {
  13. e->flt_l_32 = 0;
  14. e->flt_h_32 = 0;
  15. return;
  16. }
  17. if (n >= 32) {
  18. e->flt_l_32 = e->flt_h_32;
  19. e->flt_h_32 = 0;
  20. n -= 32;
  21. }
  22. if (n > 0) {
  23. e->flt_l_32 = (e->flt_l_32 >> 1) & 0x7FFFFFFF;
  24. e->flt_l_32 >>= (n - 1);
  25. if (e->flt_h_32 != 0) {
  26. e->flt_l_32 |= (e->flt_h_32 << (32 - n)) & 0xFFFFFFFF;
  27. e->flt_h_32 = (e->flt_h_32 >> 1) & 0x7FFFFFFF;
  28. e->flt_h_32 >>= (n - 1);
  29. }
  30. }
  31. n = -n;
  32. if (n >= 32) {
  33. e->flt_h_32 = e->flt_l_32;
  34. e->flt_l_32 = 0;
  35. n -= 32;
  36. }
  37. if (n > 0) {
  38. e->flt_h_32 = (e->flt_h_32 << n) & 0xFFFFFFFF;
  39. if (e->flt_l_32 != 0) {
  40. long l = (e->flt_l_32 >> 1) & 0x7FFFFFFF;
  41. e->flt_h_32 |= (l >> (31 - n));
  42. e->flt_l_32 = (e->flt_l_32 << n) & 0xFFFFFFFF;
  43. }
  44. }
  45. }