Ludd
Ludd

Reputation: 63

Ada95: How to use Float in Exponent?

What I've tried:

 function Get_T(I : in Integer)
                return Float is
    T:Float;
    M:Float:=Float(I);
  begin
    T:=40.0*0.5**((60.0-M)/20.0);  -- FLOAT NOT ACCEPTED IN EXPONENT
    return T;
  end Get_T;

Do I need a special package? I've been looking at Ada.Numerics.Generic_Elementary_Functions but I'm not sure how to use it.

Upvotes: 3

Views: 1317

Answers (1)

user7860670
user7860670

Reputation: 37587

You can utilize power operator defined in Ada.Numerics.Elementary_Functions package:

With Ada.Numerics.Elementary_Functions;

function Get_T(I : in Integer) return Float is
    use Ada.Numerics.Elementary_Functions;
    T: Float;
    M: Float := Float(I);
begin
    T := 40.0 * 0.5 ** ((60.0 - M) / 20.0);
    return T;
end Get_T;

Upvotes: 5

Related Questions