Hello my friends,
I’m trying to translate a Fortran program into Xojo.
This program is about finding all the roots of a polynomial “Algorithm 493: Zeros of a Real Polynomial”.
I have two questions regarding certain values.
ETA : The maximum relative representation error which can be described as the smallest positive floating-point number such that 1 + ETA > 1.
BASE : The base of the floating-point number system used.
The values below correspond to the Burroughs B6700 :
BASE = 8
ETA = .5*BASE**(1-26)
For the base should I use that of Windows 11 on my PC and with Xojo 2024, 64?
For ETA, I don’t understand the exponent (1-26).
Thanking you.
Benoît
26 is likely the number of bits of the mantissa of the floating point representation. BASE=8 means that this was an octal floating point system: I don’t know on which machine it was, but it’s probably quite old now.
Nearly all computers nowadays use the IEEE754 norm for floating point numbers. The base is 2, and the number of bits in the mantissa is 23 (32 bits numbers) or 52 (64 bits numbers).
Note that Fortran has now an intrinsic function EPSILON(x) to directly get the value of ETA
You may find it easier to translate Alan Miller’s modernized version of the algorithm, rpoly.f90. His code describes eta as
! eta the maximum relative representation error which can be described
! as the smallest positive floating point number such that
! 1.d0+eta is greater than 1.
and sets it with
eta = EPSILON(1.0)
where epsilon is an intrinsic function described here.
Miller’s code declares some variables as real(kind=dp) and some as just real. I wonder if the code works if all real variables are declared in the former way.
Whoa!
Thank you both. PierU, you introduced me to this theory about numbers in computer science and I was able to solve my translation problem. Beliavsky, thank you for the modernized version, it allowed me to better understand the previous one.
I still have errors in my translation so I downloaded FTN95 (Silverfrost Fortran).
I followed a tutorial by making a small demo program.
Then I made a copy and paste of rpoly.f90 and miraculously, it gave me the solutions of the polynomial without any error.
I will be able to test my Xojo or Delphi program step by step.
Thank you again a thousand times.