Zeptuz
Zeptuz

Reputation: 103

Dividing a character with a Float in Ada

So i´m trying to divide a character with a float using an operator, but I dont know why my code gets the error message "unexpected argument for "Position" attribute"

function "/"(Teck: in Character;
             Flyt: in Float) return Float is
  
  
begin
  
  return Float(Character'Position(Teck))/Flyt;
  
end "/";

Can somebody explain how Character'position works and what I need to change here, because I´ve used pretty much the same code previously in a different assigment.

Upvotes: 2

Views: 135

Answers (1)

Frédéric Praca
Frédéric Praca

Reputation: 1641

Regarding the ARM, characters are, for example, defined as

UC_C_Cedilla               : constant Character := 'Ç'; --Character'Val(199)

And if you read the operations on discrete types in the ARM, you'll se that the inverse attribute of Val is Pos, not Position.

Upvotes: 2

Related Questions