I'm trying to code a function using C++ and Xcode as compiler that will test if a is palindrome or not. The code works well when the argument is a "C++ born" type (such as int, long, double etc.) but I want to use the function for larger values. So I used an argument of type BigInteger. But the compiler gives an error on the line
BigInteger q = x - floor(x.toLong()/10)*10
saying that Conversion from 'double' to 'const BigInteger' is ambiguous
. Here is the whole code :
#include <iostream>
#include "BigInteger.hh"
using namespace std;
bool isPalindrom(BigInteger x){
long ch = ceil(log10(x.toUnsignedLong())), n[ch];
// cout << floor(log10(x)) + 1 << endl;
for (int i = 0; i <= ch; i++){
BigInteger q = x - floor(x.toLong()/10)*10;
n[i] = q.toInt();
// cout << n[i] << endl;
x /= 10;
}
for (long i = 0; i <= ceil(ch); i++){
if (n[i] != n[ch - i]){
return false;
}
}
return true;
}
How can I solve this problem?