File: NumConv.md

package info (click to toggle)
mocka 9905-2
  • links: PTS
  • area: non-free
  • in suites: potato, sarge, woody
  • size: 5,436 kB
  • ctags: 160
  • sloc: asm: 23,203; makefile: 124; sh: 102; ansic: 23
file content (35 lines) | stat: -rw-r--r-- 1,198 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
(******************************************************************************)
(* Copyright (c) 1988 by GMD Karlruhe, Germany				      *)
(* Gesellschaft fuer Mathematik und Datenverarbeitung			      *)
(* (German National Research Center for Computer Science)		      *)
(* Forschungsstelle fuer Programmstrukturen an Universitaet Karlsruhe	      *)
(* All rights reserved.							      *)
(* Don't modify this file under any circumstances			      *)
(******************************************************************************)

DEFINITION MODULE NumConv;

  CONST
    MaxBase = 16;

  TYPE
    tBase = [2..MaxBase];


  PROCEDURE Str2Num(VAR num: LONGCARD; base: tBase;
		    str: ARRAY OF CHAR;
		    VAR done: BOOLEAN);
    (* Convert 'str' to 'num' using 'base' *)

  PROCEDURE Num2Str(num: LONGCARD; base: tBase;
	            VAR str: ARRAY OF CHAR;
		    VAR done: BOOLEAN);
    (* Convert 'num' to 'str' using 'base' *)

  PROCEDURE AdjustWidth(VAR str: ARRAY OF CHAR; width: INTEGER; filler: CHAR);
    (* make str at least abs(width) chars long
       width >= 0: insert filler chars to the left if necessary
       width < 0 : append filler chars if necessary 
     *)

END NumConv.