Task

Write a function which tests if infinity is supported for floating point numbers (this step should be omitted for languages where the language specification already demands the existence of infinity, e.g. by demanding IEEE numbers), and if so, returns positive infinity.   Otherwise, return the largest possible positive floating point number.

For languages with several floating point types, use the type of the literal constant   1.5   as floating point type.



Related task

   Extreme floating point values


      *FLOAT 64
      PRINT FNinfinity
      END
 
      DEF FNinfinity
      LOCAL supported%, maxpos, prev, inct
      supported% = TRUE
      ON ERROR LOCAL supported% = FALSE
      IF supported% THEN = 1/0
      RESTORE ERROR
      inct = 1E10
      REPEAT
        prev = maxpos
        inct *= 2
        ON ERROR LOCAL inct /= 2
        maxpos += inct
        RESTORE ERROR
      UNTIL maxpos = prev
      = maxpos