 Options: Use Forum View Use Monospaced Font Show HTML Part by Default Show All Mail Headers Message: [<< First] [< Prev] [Next >] [Last >>] Topic: [<< First] [< Prev] [Next >] [Last >>] Author: [<< First] [< Prev] [Next >] [Last >>]

```To All,

I was very impressed by the responses I got to my earlier request for help.
I've found two ways
to solve my problem. The first involved using an unchecked conversion to
convert the float type into a modular type and then see if the difference
was less than a certain amount. I found a differnce of less than four to
suffice for my purposes. The code to implement this is shown at the bottom.

Robert Eachus' solution of using a Fixed Point representation is the one I
like best. See his earlier post for how to implement this.  As the saying
goes, "You learn something everyday."

When (if) I get a paper published on an alternative algorithm to the
Traveling Salesman Problem, I'll be sure to drop a line here giving a
pointer to it. (As a teaser, I think I've found a way to find the solution
in N**2 rather than N! time, at least for points lying on the 2D Cartesian
plane.) My plan now is to hit up the ACM's Trans. on Mathematical Software
with a paper within the next two to three months. It will be nice to see a
reference in there to an algorithm implemented in something other than Fortran!

Thanks again for all the help!

Here's my code to compare two My_Float variables.  Obviously this could
easily be turned into a generic function, but I'm going rewrite my code

function "="(Left, Right: in My_Float) return Boolean is
type MFR is mod 2**My_Float'Size;
for MFR'Size use My_Float'Size;
use MFR_IO;
function To_MFR
function To_My_Float
Left_MFR: MFR := To_MFR(Left);
Right_MFR: MFR := To_MFR(Right);
Diff: constant MFR := 4;
begin
if Left_MFR = Right_MFR then
return True;
elsif Left_MFR < Right_MFR then
if Right_MFR-Left_MFR < Diff then
return True;
else
return False;
end if;
else
if Left_MFR-Right_MFR < Diff then
return True;
else
return False;
end if;
end if;
end "=";

Thanks again,
______      __
/ ____ \    / /\  Ray Harris, 2Lt, USAF
/ /\__/ /\  / / /  Rome Lab/C3CA
/ /_/_/ / / / / /   525 Brooks Rd.
/ __   _/ / / / /    Rome, NY 13441-4505
/ /\_| |\_/ / / /     "Where Visions Become Reality"