Search code examples
mathdoubleada

How to make Ada math function use double precision (Long float)variables?


Ada's standard math functions such as sin, cos, *, /, etc support Float type variables only as input and output. Is it possible to make these functions deal with double precision or long_float for both input and output variables?


Solution

  • Actually math functions are (fortunately) supported for any precision.

    with Ada.Numerics.Generic_Elementary_Functions;
    
    ...
    
      type Real is digits 15;
    
      package REF is new Ada.Numerics.Generic_Elementary_Functions (Real);
    
      use REF;