Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.1 6/24/83; site pucc-i
Path: utzoo!watmath!clyde!burl!hou3c!hocda!houxm!ihnp4!inuxc!pur-ee!CS-Mordred!Pucc-H:Pucc-I:ags
From: ags@pucc-i (Seaman)
Newsgroups: net.lang.pascal
Subject: Re: Floating Point trunc?
Message-ID: <211@pucc-i>
Date: Sat, 18-Feb-84 12:51:14 EST
Article-I.D.: pucc-i.211
Posted: Sat Feb 18 12:51:14 1984
Date-Received: Mon, 20-Feb-84 07:16:04 EST
References: <20300001@hp-dcde.UUCP>
Organization: Purdue University Computing Center
Lines: 29

>  All I want to do is to remove the fractional part of a real number,
>  in a machine-independent fashion using vanilla J&W pascal only. 
>  You are NOT allowed to generate an integer during the calculation, ala
>   
>   real_value := trunc(real_value);   { integer overflow may occur }

Here is a quick hack which I think will do the job:

	function ftrunc(x : real) : real;
	  var y : real;
	  begin
	    y := abs(x);
	    if y <= maxint then
	      ftrunc := trunc(x)
	    else if y = y + 1.0 then
	      ftrunc := x
	    else begin
	      y := ftrunc(x/maxint) * maxint;
	      ftrunc := y + ftrunc(x-y)
	      end
	  end;

-- 

Dave Seaman
..!pur-ee!pucc-i:ags

"Against people who give vent to their loquacity 
by extraneous bombastic circumlocution."