Jacob
Jacob

Reputation: 105

How to calculate square root of integer in Ada

Hi I am a beginner in learning Ada. Can someone please tell me how to calculate square root of integers in Ada and do we have to add any packages for it?

Upvotes: 0

Views: 1070

Answers (1)

Jacob Sparre Andersen
Jacob Sparre Andersen

Reputation: 6611

When you look in the index of the reference manual, the trick is to know that even Ada shortens the name of the function to Sqrt.

The Ada standard library doesn't include a square root function for integer types, so you will have to either:

  • Convert your integer to a floating point type, use the standard library, and then convert back,

or

  • Write your own integer square root function.

Upvotes: 1

Related Questions