program decimals(decimalsp, output); (* decimals: determine the number of decimal places in a real number Dr. Thomas D. Schneider National Institutes of Health National Cancer Institute Center for Cancer Research Nanobiology Program Molecular Information Theory Group Frederick, Maryland 21702-1201 toms@ncifcrf.gov permanent email: toms@alum.mit.edu (use only if first address fails) http://www.ccrnp.ncifcrf.gov/~toms/ *) label 1; (* end of program *) const (* begin module version *) version = 1.01; (* of decimals.p 2006 Sep 24 2006 Sep 24, 1.01: clean documentation 2006 Sep 24, 1.00: origin *) updateversion = 1.00; (* defines lowest acceptable current parameter file *) (* end module version *) (* begin module describe.decimals *) (* name decimals: determine the number of decimal places in a real number synopsis decimals(decimalsp: in, output: out) files decimalsp: parameters to control the program. The file must contain the following parameters, one per line: parameterversion: The version number of the program. This allows the user to be warned if an old parameter file is used. output: messages to the user description Determine the number of decimal places that a real number can hold. This is done by repeatedly dividing by 2 until the number becomes zero. examples documentation see also author Thomas Dana Schneider bugs technical notes *) (* end module describe.decimals *) var decimalsp: text; (* file used by this program *) (* begin module halt *) procedure halt; (* stop the program. the procedure performs a goto to the end of the program. you must have a label: label 1; declared, and also the end of the program must have this label: 1: end. examples are in the module libraries. this is the only goto in the delila system. *) begin writeln(output,' program halt.'); goto 1 end; (* end module halt version = 'delmod 6.16 84 mar 12 tds/gds'; *) (* begin module decimals.themain *) procedure themain(var decimalsp: text); (* the main procedure of the program *) var parameterversion: real; (* parameter version number *) x: real; (* the number *) p: real; (* previous x *) begin writeln(output,'decimals ',version:4:2); reset(decimalsp); readln(decimalsp, parameterversion); if round(100*parameterversion) < round(100*updateversion) then begin writeln(output, 'You have an old parameter file!'); halt end; x := 1.0; while x > 0 do begin writeln (output, x:1); x := x / 2.0; end; end; (* end module decimals.themain *) begin themain(decimalsp); 1: end.