home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / TPTOOL5.ZIP / STOF.INC < prev    next >
Encoding:
Text File  |  1987-05-22  |  1.1 KB  |  49 lines

  1.  
  2. #log 4-byte Single to Floating point conversion
  3.  
  4. type
  5.   single    = array[0..3] of byte;
  6.   double    = array[0..7] of byte;
  7.  
  8.  
  9. function stof(B: single): real;
  10.    {convert 4 byte single to real}
  11. var
  12.    PasReal:  real;
  13.    PasArray: array [0 .. 5] of byte absolute PasReal;
  14.    BasArray: array [0 .. 3] of byte absolute B;
  15. begin
  16.    fillchar(PasArray[0],3,0);
  17.    move(BasArray[0],PasArray[3],3);
  18.    PasArray[0]:=BasArray[3];
  19.    stof := PasReal;
  20. end;
  21.  
  22.  
  23. procedure ftos(PasReal: real; var B: single);
  24.    {convert real to 4 byte single}
  25. var
  26.    PasArray: array [0 .. 5] of byte absolute PasReal;
  27.    BasArray: array [0 .. 3] of byte absolute B;
  28. begin
  29.    move(PasArray[3],BasArray[0],3);
  30.    BasArray[3]:=PasArray[0];
  31. end;
  32.  
  33.  
  34. function dtof(B: double): real;
  35.    {convert 8 byte double to real}
  36. var
  37.    PasReal:  real;
  38.    PasArray: array [0 .. 5] of byte absolute PasReal;
  39.    BasArray: array [0 .. 7] of byte absolute B;
  40. begin
  41.    fillchar(PasArray[0],3,0);
  42.    move(BasArray[0],PasArray[3],3);
  43.    PasArray[0]:=BasArray[3];
  44.    PasReal := 0;  {function not implemented}
  45.    dtof := PasReal;
  46. end;
  47.  
  48.  
  49.