home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3.4.17 [SPARC, PA-RISC] / nextstep33_risc.iso / NextLibrary / TeX / tex / src / texview / scalewidth.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-09-20  |  859 b   |  27 lines

  1. /*
  2.  *   scalewidth.c of dvisw software package.  This code is copyright (C) 1985
  3.  *   by Radical Eye Software.
  4.  *
  5.  *   Scales the width values.  Takes two thirty-two bit integers, multiplies
  6.  *   them, divides them by 2^20, and returns the thirty-two bit result.
  7.  *   The first integer, the width in FIXes, can lie between -2^24 and 2^24-1.
  8.  *   The second integer, the scale factor, can lie between 0 and 2^27-1.  The
  9.  *   arithmetic must be exact.  The answer is truncated to an integer.
  10.  *
  11.  *   Since this math is special, we put it in its own file.  It is the only
  12.  *   place in the program where such accuracy is required.
  13.  */
  14. #include "structures.h"
  15.  
  16. integer
  17. scalewidth(a, b)
  18.     register integer a, b ;
  19. {
  20.   register integer al, bl ;
  21.   al = a & 32767 ;
  22.   bl = b & 32767 ;
  23.   a >>= 15 ;
  24.   b >>= 15 ;
  25.   return ( ((al*bl/32768) + a*bl+al*b)/32 + a*b*1024) ;
  26. }
  27.