I am wondering what is the best possible way to check if a number is an integer (or super close to it) in MPIR. I am taking the square root of a number with mpf_sqrt()
and then I want to check if the square root yields an integer. With java I use .remainder()
that is used with BigDecimal
and then see if the remainder is greater than .99999 or less than 1.000001. But I dont see a remainder()
or modulus for mpf's. I am using Visual Studio C++. All help is appreciated!
Asked
Active
Viewed 188 times
1

Javia1492
- 862
- 11
- 28

Seth Kitchen
- 1,526
- 19
- 53
-
2I assume that the original number is an integer (the sqrt cannot be an integer otherwise). Then mpz_perfect_square_p can help. – Marc Glisse May 27 '15 at 13:38
-
thanks I am unfamiliar with that. I will look into it – Seth Kitchen May 27 '15 at 13:39
-
Otherwise you should be using MPFR for multi-precision floats, GMP is for integers and rationals, its mpf component is only kept for legacy. – Marc Glisse May 27 '15 at 13:42