Here's a puzzle for you floating-point wizards out there. I have to translate the following snippet of FORTRAN code to D:

      REAL B,Q,T
C     ------------------------------
C     |*** COMPUTE MACHINE BASE ***|
C     ------------------------------
      T = 1.
10    T = T + T
      IF ( (1.+T)-T .EQ. 1. ) GOTO 10
      B = 0.
20    B = B + 1
      IF ( T+B .EQ. T ) GOTO 20
      IF ( T+2.*B .GT. T+B ) GOTO 30
      B = B + B
30    Q = ALOG(B)
      Q = .5/Q

Of course I could just do a direct translation, but I have a hunch that T, B, and Q can be expressed in terms of real.epsilon, real.min and so forth. I have no idea how, though. Any ideas?

(I am especially puzzled by the line after l.20. How can this test ever be true? Is the fact that the 1 in l.20 is an integer literal significant?)

-Lars

Reply via email to