Hi,

The sqrt function does not accept integers of type unsigned long long int. Is there a pre-exisiting C++/C standard function that can compute square roots of integers of that size?

Thanks in advance,
Caelan.

Recommended Answers

Your only options appear to be:

  • Use long double
  • Make your own function
Jump to Post

C++11 will do it, but will cast the parameter to double first.

Jump to Post

All 6 Replies

Your only options appear to be:

  • Use long double
  • Make your own function

C++11 will do it, but will cast the parameter to double first.

Ok. So how would I go about making my own function to do it? I, not entirely sure how to write an efficient square root function.

Oh ok. Thanks a lot. I will have a good read of that.

And this will help with integer roots: http://en.wikipedia.org/wiki/Integer_square_root
It may be more to your needs. Do note that the output still needs to be a floating point value (float or double).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.