home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / CNC11TP.ZIP / CONIC.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1989-01-20  |  2.5 KB  |  96 lines

  1. { Copyright (C) 1989 Adam Fritz, 133 Main St., Afton, N.Y. 13730 }
  2.  
  3. const
  4.    dr : single = 0.5 ;
  5.    idr : integer = 32 ;
  6.  
  7. type
  8.    lohi = record loint : integer ; hiint : integer ; end ;
  9.  
  10. {**********************************************************}
  11.  
  12.    function SwapLong ( n : longint ) : longint ;
  13.       { interchange high and low order 16 bit words }
  14.    var
  15.       m : integer ;
  16.       nlohi         : lohi absolute n ;
  17.    begin
  18.       m := nlohi.loint ;
  19.       nlohi.loint := nlohi.hiint ;
  20.       nlohi.hiint := m ;
  21.       SwapLong := n
  22.    end ;
  23.  
  24. {**********************************************************}
  25.  
  26.    function LongHi ( n : longint ) : longint ;
  27.       { move high order 16 bits to low with sign extend }
  28.    var
  29.       nlohi         : lohi absolute n ;
  30.    begin
  31.       nlohi.loint := nlohi.hiint ;
  32.       if n >= 0 then
  33.          nlohi.hiint := 0
  34.       else
  35.          nlohi.hiint := -1 ;
  36.       LongHi := n
  37.    end ;
  38.  
  39. {**********************************************************}
  40.  
  41.    function RoundScaleB3 ( n : integer ) : integer ;
  42.       { round and scale to B0 a fixed point value scaled B3 }
  43.    begin
  44.       if n >= 0 then
  45.          RoundScaleB3 := (n + 4) div 8
  46.       else
  47.          RoundScaleB3 := (n - 4) div 8
  48.    end ;
  49.  
  50. {**********************************************************}
  51.  
  52.    function RoundScaleB6 ( n : integer ) : integer ;
  53.       { round and scale to B0 a fixed point value scaled B6 }
  54.    begin
  55.       if n >= 0 then
  56.          RoundScaleB6 := (n + 32) div 64
  57.       else
  58.          RoundScaleB6 := (n - 32) div 64
  59.    end ;
  60.  
  61. {**********************************************************}
  62.  
  63.    function RoundScaleB16 ( n : longint ) : longint ;
  64.       { round and scale to B0 a fixed point value scaled B16 }
  65.    var
  66.       nlohi         : lohi absolute n ;
  67.    begin
  68.       if n >= 0 then begin
  69.          n := n + 32768 ;
  70.          nlohi.loint := nlohi.hiint ;
  71.          nlohi.hiint := 0
  72.       end
  73.       else begin
  74.          n := n - 32768 ;
  75.          nlohi.loint := nlohi.hiint ;
  76.          nlohi.hiint := -1
  77.       end ;
  78.       RoundScaleB16 := n
  79.    end ;
  80.  
  81. {**********************************************************}
  82.  
  83.    function sinh ( x : single ) : single ;
  84.      { hyperbolic sine }
  85.    begin
  86.       sinh := (exp(x) - exp(-x))/2.0
  87.    end ;
  88.  
  89.    function cosh ( x : single ) : single ;
  90.       { hyperbolic cosine }
  91.    begin
  92.       cosh := (exp(x) + exp(-x))/2.0
  93.    end ;
  94.  
  95. { Copyright (C) 1989 Adam Fritz, 133 Main St., Afton, N.Y. 13730 }
  96.