home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / d / drcpas10.zip / IEEE.PAS < prev    next >
Pascal/Delphi Source File  |  1992-11-17  |  2KB  |  68 lines

  1. {$A+,B-,D-,F-,L-,N+,O-,R-,S+,V-}
  2. Unit IEEE;
  3.  
  4. (* by David R. Conrad, for Turbo Pascal 5.5
  5.  
  6.    This code is not copyrighted, you may use it freely.
  7.    There are no guarantees, either expressed or implied,
  8.    as to either merchantability or fitness for a particular
  9.    purpose.  The author's liability is limited to the amount
  10.    you paid for it.
  11.  
  12.    David R. Conrad, 17 Nov 92
  13.    David_Conrad@mts.cc.wayne.edu
  14.    dave@michigan.com
  15. *)
  16.  
  17. Interface
  18.  
  19. (* this unit contains the IEEE versions of the tools.pas routines:
  20.    Commarstr, NumrStr and ZerorStr
  21. *)
  22.  
  23. Function CommaeStr (E : Extended; D : Byte) : String;
  24. Function NumeStr (E : Extended; W,D : Byte) : String;
  25. Function ZeroeStr (E : Extended; W,D : Byte) : String;
  26.  
  27. Implementation
  28.  
  29. Function CommaeStr (E : Extended; D : Byte) : String;
  30. var
  31.   s,st : string;
  32.   len,alen,num,cnt : byte;
  33.   eh,et : extended;
  34. begin
  35.   eh := Int(E);
  36.   et := Frac(E);
  37.   str (eh:0:0,s);
  38.   str (et:0:D,st);
  39.   delete (st,1,1);
  40.   len := length(s);
  41.   If E >= 0 then alen := pred(len) Else alen := pred(len) - 1;
  42.   num := alen DIV 3;
  43.   for cnt := 1 to num do
  44.     Insert (',',s,len - cnt * 3 + 1);
  45.   CommaeStr := s + st;
  46. end;
  47.  
  48. Function NumeStr (E : Extended; W,D : Byte) : String;
  49. var
  50.   s : string;
  51. begin
  52.   str (E:W:D,s);
  53.   NumeStr := s;
  54. end;
  55.  
  56. Function ZeroeStr (E : Extended; W,D : Byte) : String;
  57. var
  58.   s   : string;
  59.   cnt : byte;
  60. begin
  61.   str (E:W:D,s);
  62.   for cnt := 1 to length(s) do
  63.     If s[cnt] = ' ' then s[cnt] := '0';
  64.   ZeroeStr := s;
  65. end;
  66.  
  67. End.
  68.