Link to home
Start Free TrialLog in
Avatar of mafendee
mafendee

asked on

to convert 100 decimal digit integer to binary, ternary and others

dear all,

i am trying to find a program in c/c++ which is capable of taking input of 100 decimal digit and convert to other radix base number.

does anyone out there who can help me out to solve this problem?

i would hugely appreciate that! Thanx.
Avatar of sunnycoder
sunnycoder
Flag of India image

http://gmplib.org/
check Function: char * mpz_get_str (char *str, int base, mpz_t op)
http://gmplib.org/manual/Converting-Integers.html#Converting-Integers
You also posted in the C# section, is C# ok? Shouldn't be too hard to convert to C++. Just created, tested, might be not totally free of errors and if performance is important, you might want to use a stringbuilder instead. Works for bases of 1-16, but easily extensible:


private string ConvertToRadix(int number, int radix)
{
    string[] digits = new string[] {"0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"};
 
    if (radix < 1 || radix > 16)
        throw new ArgumentOutOfRangeException("Radix must be between 1 and 16 inclusive");
 
    if (radix == 1)
        return new string('1', number);
 
    string retVal = "";
    for (int i = number; i > 0; i = i / radix)
    {
        int rest = i % radix;
        retVal = digits[rest] + retVal;
    }
    return retVal;
}

Open in new window

For your convenience, output for number = 12345:

{02}-base:  11000000111001
{03}-base:  121221020
{04}-base:  3000321
{05}-base:  343340
{06}-base:  133053
{07}-base:  50664
{08}-base:  30071
{09}-base:  17836
{10}-base:  12345
{11}-base:  9303
{12}-base:  7189
{13}-base:  5808
{14}-base:  46db
{15}-base:  39d0
{16}-base:  3039
Avatar of mafendee
mafendee

ASKER

abel, i am not much into C# and do you think your program works with big integers.

sunnycoder, i have installed the gmp but am having a problem when trying to compile the example program. example program is below and the error as well. any idea why?

=======================example program========================================

#include <stdlib.h>             /* Standard Lib    ISOC  */
#include <stdio.h>              /* I/O lib         ISOC  */
#include <stdarg.h>             /* Variable args   ISOC  */
#include <gmp.h>                /* GNU GMP Library       */
using namespace std;

// 6005662386412099
// 600566238641209
// 3107418240490043721350750035888567930037346022842727545720161948823206440518081504556346829671723286782437916272838033415471073108501919548529007337724822783525742386454014691736602477652346609

int main(int argc, char *argv[]);

int main(int argc, char *argv[]) {
  mpz_t m, n, p, k;
  int i,j;

  // Get the number to play with
  if(argc < 2) {
    printf("No argument provided, using built in number\n");
    mpz_init_set_str(m, "6005662386412099", 10);
  } else {
    mpz_init_set_str(m, argv[1], 10);
  }

  // Output the number we are working on
  printf("        m: ");
  mpz_out_str(stdout, 10, m);
  printf("\n");

  // Check for 2|m
  if(mpz_divisible_ui_p(m, 2)) {
    printf("FOUND p|m: 2\n");
    exit(1);
  }

  // Compute k=SQRT(M)
  mpz_init(k);
  mpz_sqrt(k, m);
  gmp_printf("  SQRT(m): %Zd\n", k);

  // 2|SQRT(M) => p=SQRT(M)+5, else p=SQRT(M)+4
  mpz_init(p);
  if(mpz_divisible_ui_p(k, 2)) {
    mpz_add_ui(p, k, 5);
  } else {
    mpz_add_ui(p, k, 4);
  }

  // Move DOWN from SQRT(m) by two looking for something that | m
  mpz_init(n);
  for(i=0,j=0;1 || i<10000000;i++) {
    // Subtract 2, and test for |.
    mpz_sub_ui(p, p, 2);
    if(mpz_divisible_p(m, p)) {
      gmp_printf("FOUND p|m: %Zd\n", p);
      if(mpz_cmp_ui(p, 1) == 0)
        printf("m was prime!\n");
      exit(1);
    }
    // Print status every 100K tests
    j++;
    if(j>100000) {
      j=0;
      mpz_sub(n, k, p);
      gmp_printf("  CHECKED: %Zd\n", n);
    }
  }


  // If we got here, then we didn't find the value..
  printf("No Factors Found\n");
  exit(0);

  return 0;
}


==========================compilation error=========================================
Compiler: Default compiler
Executing  g++.exe...
g++.exe "D:\my program\tt.cpp" -o "D:\my program\tt.exe"    -I"C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include"  -I"C:\Dev-Cpp\include\c++\3.4.2\backward"  -I"C:\Dev-Cpp\include\c++\3.4.2\mingw32"  -I"C:\Dev-Cpp\include\c++\3.4.2"  -I"C:\Dev-Cpp\include"   -L"C:\Dev-Cpp\lib"
D:\my program\tt.cpp:4:60: gmp.h: No such file or directory
D:\my program\tt.cpp: In function `int main(int, char**)':
D:\my program\tt.cpp:14: error: `mpz_t' undeclared (first use this function)
D:\my program\tt.cpp:14: error: (Each undeclared identifier is reported only once for each function it appears in.)
D:\my program\tt.cpp:14: error: expected `;' before "m"

D:\my program\tt.cpp:20: error: `m' undeclared (first use this function)
D:\my program\tt.cpp:20: error: `mpz_init_set_str' undeclared (first use this function)
D:\my program\tt.cpp:27: error: `mpz_out_str' undeclared (first use this function)
D:\my program\tt.cpp:31: error: `mpz_divisible_ui_p' undeclared (first use this function)
D:\my program\tt.cpp:37: error: `k' undeclared (first use this function)
D:\my program\tt.cpp:37: error: `mpz_init' undeclared (first use this function)
D:\my program\tt.cpp:38: error: `mpz_sqrt' undeclared (first use this function)
D:\my program\tt.cpp:39: error: `gmp_printf' undeclared (first use this function)
D:\my program\tt.cpp:42: error: `p' undeclared (first use this function)
D:\my program\tt.cpp:44: error: `mpz_add_ui' undeclared (first use this function)
D:\my program\tt.cpp:50: error: `n' undeclared (first use this function)
D:\my program\tt.cpp:53: error: `mpz_sub_ui' undeclared (first use this function)
D:\my program\tt.cpp:54: error: `mpz_divisible_p' undeclared (first use this function)
D:\my program\tt.cpp:56: error: `mpz_cmp_ui' undeclared (first use this function)
D:\my program\tt.cpp:64: error: `mpz_sub' undeclared (first use this function)

Execution terminated
> abel, i am not much into C# and do you think your program works with big integers.

The function would work with any integer, but C#'s largest integer, native, is the 64 unsigned bit integer, which goes up to 18446744073709551616. Not sure what your task is, but if you need larger numbers, you can always use the BigInteger classes, free for download here: http://www.codeproject.com/KB/cs/biginteger.aspx (commercial packages also exist).

To work with 64 bit numbers, you'll have to change the function signature to:

private string ConvertToRadix(Int64 number, Int64 radix)

If you want the same code for C++ I can try to transform it. The task at hand shouldn't be too hard. Would be handy though to know what you need it for and what size the input can become.
>D:\my program\tt.cpp:4:60: gmp.h: No such file or directory

It was unable to find the required header file ... Search and locate the directory where it has been installed.
Ah, I think I got it "to convert 100 decimal digit integer to binary, ternary and others" means: "integers of 100 digits" instead of "100 integers with decimal digits".

Here's the same sample code with the BigInteger class from the J# redistributable package (J# redistributable package 2nd ed download @ microsoft). You can also use the BigInteger class from CodeProject BigInteger.

While I was working on the transformation to big integers of the ConverToRadix method, I noticed that the J# redistributable already had this method in the BigInteger class, through toString(radix) (note that it is "toString", not "ToString"). Though the self-made code looks as below, one line would've been sufficient:

System.Console.WriteLine (new BigInteger(inputStringOfBigInteger).toString(radix));

The internal radix works from base 2 to base 36.

// put the following line on top of the file
// after creating a reference to vjslib.dll:
using java.math;
 
/// <summary>
/// Converts big integers to any radix between 1-16
/// </summary>
/// <param name="number">Any positive number in base 10 as string</param>
/// <param name="radix">A radix between 1 and 16 incl.</param>
/// <returns></returns>
private string ConvertToRadix(string number, int radix)
{
    string[] digits = new string[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f" };
    BigInteger biInput = new BigInteger(number);
    BigInteger biRadix = new BigInteger(radix.ToString());
 
    string retVal = "";
    BigInteger[] divAndRem;
 
    do
    {
        divAndRem = biInput.divideAndRemainder(biRadix);
        retVal = digits[divAndRem[1].longValue()] + retVal;
        biInput = divAndRem[0];
    } while (divAndRem[0].bitCount() > 0);
 
    return retVal;
}

Open in new window

sunnycoder,

i changed the directory to "#include <C:/Dev-Cpp/gmp-4.2.4/gmp.h>" and now i got this error msg:

Compiler: Default compiler
Executing  g++.exe...
g++.exe "D:\my program\tt1.cpp" -o "D:\my program\tt1.exe"    -I"C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include"  -I"C:\Dev-Cpp\include\c++\3.4.2\backward"  -I"C:\Dev-Cpp\include\c++\3.4.2\mingw32"  -I"C:\Dev-Cpp\include\c++\3.4.2"  -I"C:\Dev-Cpp\include"   -L"C:\Dev-Cpp\lib"
D:\my program\tt1.cpp: In function `int main()':
D:\my program\tt1.cpp:5: error: `mpz_class' undeclared (first use this function)
D:\my program\tt1.cpp:5: error: (Each undeclared identifier is reported only once for each function it appears in.)
D:\my program\tt1.cpp:5: error: expected `;' before "a"
D:\my program\tt1.cpp:6: error: `a' undeclared (first use this function)
D:\my program\tt1.cpp:7: error: `b' undeclared (first use this function)
D:\my program\tt1.cpp:8: error: `c' undeclared (first use this function)

Execution terminated

--------------------------------

any idea???
#include <gmpxx.h>
You'd also need these flags
-lgmpxx -lgmp
sunnycoder,

this is my program now (am trying with a short one).

#include <iostream>
#include <stdio.h>
#include <C:/Dev-Cpp/gmp-4.2.4/gmp.h>
#include <C:/Dev-Cpp/gmp-4.2.4/gmpxx.h>

using namespace std;
      
int main () {
      mpz_class a, b, c;
      a = 1234;
      b = "-5678";
      c = a+b;
      cout << "sum is " << c << "\n";
      cout << "absolute value is " << abs(c) << "\n";
      cin >> a;
 return 0;
}


An error msg i am getting is

Compiler: Default compiler
Executing  g++.exe...
g++.exe "D:\myprogram\tt1.cpp" -o "D:\myprogram\tt1.exe"    -I"C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include"  -I"C:\Dev-Cpp\include\c++\3.4.2\backward"  -I"C:\Dev-Cpp\include\c++\3.4.2\mingw32"  -I"C:\Dev-Cpp\include\c++\3.4.2"  -I"C:\Dev-Cpp\include"   -L"C:\Dev-Cpp\lib"
In file included from D:\myprogram\tt1.cpp:4:
C:/Dev-Cpp/gmp-4.2.4/gmpxx.h:41:17: gmp.h: No such file or directory

Execution terminated

I am sure gmp.h and gmpxx.h are inside the directory i have included.

The command i used to compile

gcc d:/myprogram/tt1.cpp -lgmpxx -lgmp

...need help still.
Strange, it doesn't show that whole code that I cut 'n' pasted there (the vertical bar doesn't show int he code snippet section).

I understand from your other comments that you'll to stick to C++, so I'll leave you to it. But if you want to switch at some point to use C#, which has it already built in, check above and below:

System.Console.WriteLine (new BigInteger(inputStringOfBigInteger).toString(radix));

OR:

private string ConvertToRadix(string number, int radix)
{
    string[] digits = new string[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f" };
    BigInteger biInput = new BigInteger(number);
    BigInteger biRadix = new BigInteger(radix.ToString());

    string retVal = "";
    BigInteger[] divAndRem;

    do
    {
        divAndRem = biInput.divideAndRemainder(biRadix);
        retVal = digits[divAndRem[1].longValue()] + retVal;
        biInput = divAndRem[0];
    } while (divAndRem[0].bitCount() > 0);

    return retVal;
}


SOLUTION
Avatar of abel
abel
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>C:/Dev-Cpp/gmp-4.2.4/gmpxx.h:41:17: gmp.h: No such file or directory
>I am sure gmp.h and gmpxx.h are inside the directory i have included.

Something is amiss. Are both files in the same directory? It obviously found gmpxx.h but could not find gmp.h
Since you're using Dev-C++, why don't you make use of their package system ? It's a lot easier, and installs in the standard directories, avoiding the need to specify full paths.

Here's the DevPak for GMP v4.2.4 :

    http://devpaks.org/details.php?devpak=247
Infinity08,

now i have installed GMP package (ONLY) from package manager window. is there any installation guidelines or so? is there any other i should have installed?

anyway, when i compile this program

#include <stdio.h>
#include <iostream>
#include <gmp.h>
#include <gmpxx.h>

using namespace std;
      
int main () {
      mpz_class a, b, c;
      a = 1234;
      b = "-5678";
      c = a+b;
      cout << "sum is " << c << "\n";
      cout << "absolute value is " << abs(c) << "\n";
      cin >> a;
 return 0;
}


I got the following error message

Compiler: Default compiler
Executing  g++.exe...
g++.exe "D:\myprogram\tt1.cpp" -o "D:\myprogram\tt1.exe"    -I"C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include"  -I"C:\Dev-Cpp\include\c++\3.4.2\backward"  -I"C:\Dev-Cpp\include\c++\3.4.2\mingw32"  -I"C:\Dev-Cpp\include\c++\3.4.2"  -I"C:\Dev-Cpp\include"   -L"C:\Dev-Cpp\lib"
C:\DOCUME~1\mafendee\LOCALS~1\Temp/ccEVaaaa.o(.text$_ZN10__gmp_exprIA1_12__mpz_structS1_ED1Ev[__gmp_expr<__mpz_struct [1], __mpz_struct [1]>::~__gmp_expr()]+0xd):tt1.cpp: undefined reference to `__gmpz_clear'
C:\DOCUME~1\mafendee\LOCALS~1\Temp/ccEVaaaa.o(.text$_ZN10__gmp_exprIA1_12__mpz_structS1_EaSEPKc[__gmp_expr<__mpz_struct [1], __mpz_struct [1]>::operator=(char const*)]+0x55):tt1.cpp: undefined reference to `__gmpz_set_str'
C:\DOCUME~1\mafendee\LOCALS~1\Temp/ccEVaaaa.o(.text$_ZN10__gmp_exprIA1_12__mpz_structS1_EaSEi[__gmp_expr<__mpz_struct [1], __mpz_struct [1]>::operator=(int)]+0x14):tt1.cpp: undefined reference to `__gmpz_set_si'
C:\DOCUME~1\mafendee\LOCALS~1\Temp/ccEVaaaa.o(.text$_ZN10__gmp_exprIA1_12__mpz_structS1_EC1Ev[__gmp_expr<__mpz_struct [1], __mpz_struct [1]>::__gmp_expr()]+0xd):tt1.cpp: undefined reference to `__gmpz_init'
C:\DOCUME~1\mafendee\LOCALS~1\Temp/ccEVaaaa.o(.text$_ZlsIA1_12__mpz_structERSoS2_RK10__gmp_exprIT_S4_E[std::basic_ostream<char, std::char_traits<char> >& operator<< <__mpz_struct [1]>(std::basic_ostream<char, std::char_traits<char> >&, __gmp_expr<__mpz_struct [1], __mpz_struct [1]> const&)]+0x1c):tt1.cpp: undefined reference to `operator<<(std::ostream&, __mpz_struct const*)'
C:\DOCUME~1\mafendee\LOCALS~1\Temp/ccEVaaaa.o(.text$_ZlsIA1_12__mpz_struct16__gmp_unary_exprI10__gmp_exprIS1_S1_E18__gmp_abs_functionEERSoS7_RKS3_IT_T0_E[std::basic_ostream<char, std::char_traits<char> >& operator<< <__mpz_struct [1], __gmp_unary_expr<__gmp_expr<__mpz_struct [1], __mpz_struct [1]>, __gmp_abs_function> >(std::basic_ostream<char, std::char_traits<char> >&, __gmp_expr<__mpz_struct [1], __gmp_unary_expr<__gmp_expr<__mpz_struct [1], __mpz_struct [1]>, __gmp_abs_function> > const&)]+0x6b):tt1.cpp: undefined reference to `operator<<(std::ostream&, __mpz_struct const*)'
C:\DOCUME~1\mafendee\LOCALS~1\Temp/ccEVaaaa.o(.text$_ZrsIA1_12__mpz_structERSiS2_R10__gmp_exprIT_S4_E[std::basic_istream<char, std::char_traits<char> >& operator>><__mpz_struct [1]>(std::basic_istream<char, std::char_traits<char> >&, __gmp_expr<__mpz_struct [1], __mpz_struct [1]>&)]+0x1c):tt1.cpp: undefined reference to `operator>>(std::istream&, __mpz_struct*)'
C:\DOCUME~1\mafendee\LOCALS~1\Temp/ccEVaaaa.o(.text$_ZN10__gmp_exprIA1_12__mpz_structS1_EC1IS1_16__gmp_unary_exprIS2_18__gmp_abs_functionEEERKS_IT_T0_E[__gmp_expr<__mpz_struct [1], __mpz_struct [1]>::__gmp_expr<__mpz_struct [1], __gmp_unary_expr<__gmp_expr<__mpz_struct [1], __mpz_struct [1]>, __gmp_abs_function> >(__gmp_expr<__mpz_struct [1], __gmp_unary_expr<__gmp_expr<__mpz_struct [1], __mpz_struct [1]>, __gmp_abs_function> > const&)]+0xd):tt1.cpp: undefined reference to `__gmpz_init'
C:\DOCUME~1\mafendee\LOCALS~1\Temp/ccEVaaaa.o(.text$_ZN17__gmp_binary_plus4evalEP12__mpz_structPKS0_S3_[__gmp_binary_plus::eval(__mpz_struct*, __mpz_struct const*, __mpz_struct const*)]+0x1b):tt1.cpp: undefined reference to `__gmpz_add'
C:\DOCUME~1\mafendee\LOCALS~1\Temp/ccEVaaaa.o(.text$__gmpz_abs[___gmpz_abs]+0x1d):tt1.cpp: undefined reference to `__gmpz_set'
collect2: ld returned 1 exit status

Execution terminated

----------------------------------
gmp.h and gmpxx.h were installed inside C:/Dev-Cpp/include/

any ideas?
-lgmpxx -lgmp
sunnycoder,

when i compile the program from command prompt using "g++ d:/myprogram/tt1.cpp -lgmpxx -lgmp", there is no error msg. but if i compile from Dev-C++ 4.9.9.2 environment i got this error msg

Compiler: Default compiler
Executing  g++.exe...
g++.exe "D:\myprogram\tt1.cpp" -o "D:\myprogram\tt1.exe"    -I"C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include"  -I"C:\Dev-Cpp\include\c++\3.4.2\backward"  -I"C:\Dev-Cpp\include\c++\3.4.2\mingw32"  -I"C:\Dev-Cpp\include\c++\3.4.2"  -I"C:\Dev-Cpp\include"   -L"C:\Dev-Cpp\lib"
C:\DOCUME~1\mafendee\LOCALS~1\Temp/ccU9baaa.o(.text$_ZN10__gmp_exprIA1_12__mpz_structS1_ED1Ev[__gmp_expr<__mpz_struct [1], __mpz_struct [1]>::~__gmp_expr()]+0xd):tt1.cpp: undefined reference to `__gmpz_clear'
C:\DOCUME~1\mafendee\LOCALS~1\Temp/ccU9baaa.o(.text$_ZN10__gmp_exprIA1_12__mpz_structS1_EaSEPKc[__gmp_expr<__mpz_struct [1], __mpz_struct [1]>::operator=(char const*)]+0x55):tt1.cpp: undefined reference to `__gmpz_set_str'
C:\DOCUME~1\mafendee\LOCALS~1\Temp/ccU9baaa.o(.text$_ZN10__gmp_exprIA1_12__mpz_structS1_EaSEi[__gmp_expr<__mpz_struct [1], __mpz_struct [1]>::operator=(int)]+0x14):tt1.cpp: undefined reference to `__gmpz_set_si'
C:\DOCUME~1\mafendee\LOCALS~1\Temp/ccU9baaa.o(.text$_ZN10__gmp_exprIA1_12__mpz_structS1_EC1Ev[__gmp_expr<__mpz_struct [1], __mpz_struct [1]>::__gmp_expr()]+0xd):tt1.cpp: undefined reference to `__gmpz_init'
C:\DOCUME~1\mafendee\LOCALS~1\Temp/ccU9baaa.o(.text$_ZlsIA1_12__mpz_structERSoS2_RK10__gmp_exprIT_S4_E[std::basic_ostream<char, std::char_traits<char> >& operator<< <__mpz_struct [1]>(std::basic_ostream<char, std::char_traits<char> >&, __gmp_expr<__mpz_struct [1], __mpz_struct [1]> const&)]+0x1c):tt1.cpp: undefined reference to `operator<<(std::ostream&, __mpz_struct const*)'
C:\DOCUME~1\mafendee\LOCALS~1\Temp/ccU9baaa.o(.text$_ZlsIA1_12__mpz_struct16__gmp_unary_exprI10__gmp_exprIS1_S1_E18__gmp_abs_functionEERSoS7_RKS3_IT_T0_E[std::basic_ostream<char, std::char_traits<char> >& operator<< <__mpz_struct [1], __gmp_unary_expr<__gmp_expr<__mpz_struct [1], __mpz_struct [1]>, __gmp_abs_function> >(std::basic_ostream<char, std::char_traits<char> >&, __gmp_expr<__mpz_struct [1], __gmp_unary_expr<__gmp_expr<__mpz_struct [1], __mpz_struct [1]>, __gmp_abs_function> > const&)]+0x6b):tt1.cpp: undefined reference to `operator<<(std::ostream&, __mpz_struct const*)'
C:\DOCUME~1\mafendee\LOCALS~1\Temp/ccU9baaa.o(.text$_ZrsIA1_12__mpz_structERSiS2_R10__gmp_exprIT_S4_E[std::basic_istream<char, std::char_traits<char> >& operator>><__mpz_struct [1]>(std::basic_istream<char, std::char_traits<char> >&, __gmp_expr<__mpz_struct [1], __mpz_struct [1]>&)]+0x1c):tt1.cpp: undefined reference to `operator>>(std::istream&, __mpz_struct*)'
C:\DOCUME~1\mafendee\LOCALS~1\Temp/ccU9baaa.o(.text$_ZN10__gmp_exprIA1_12__mpz_structS1_EC1IS1_16__gmp_unary_exprIS2_18__gmp_abs_functionEEERKS_IT_T0_E[__gmp_expr<__mpz_struct [1], __mpz_struct [1]>::__gmp_expr<__mpz_struct [1], __gmp_unary_expr<__gmp_expr<__mpz_struct [1], __mpz_struct [1]>, __gmp_abs_function> >(__gmp_expr<__mpz_struct [1], __gmp_unary_expr<__gmp_expr<__mpz_struct [1], __mpz_struct [1]>, __gmp_abs_function> > const&)]+0xd):tt1.cpp: undefined reference to `__gmpz_init'
C:\DOCUME~1\mafendee\LOCALS~1\Temp/ccU9baaa.o(.text$_ZN17__gmp_binary_plus4evalEP12__mpz_structPKS0_S3_[__gmp_binary_plus::eval(__mpz_struct*, __mpz_struct const*, __mpz_struct const*)]+0x1b):tt1.cpp: undefined reference to `__gmpz_add'
C:\DOCUME~1\mafendee\LOCALS~1\Temp/ccU9baaa.o(.text$__gmpz_abs[___gmpz_abs]+0x1d):tt1.cpp: undefined reference to `__gmpz_set'
collect2: ld returned 1 exit status

Execution terminated
---------------------------------------------

i thought the compilation from the prompt was OK but when i changed the value of integer a = 123412412342141243134141 (very bit number) then i got this msg (from both methods of compilations)

Compiler: Default compiler
Executing  g++.exe...
g++.exe "D:\myprogram\tt1.cpp" -o "D:\myprogram\tt1.exe"    -I"C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include"  -I"C:\Dev-Cpp\include\c++\3.4.2\backward"  -I"C:\Dev-Cpp\include\c++\3.4.2\mingw32"  -I"C:\Dev-Cpp\include\c++\3.4.2"  -I"C:\Dev-Cpp\include"   -L"C:\Dev-Cpp\lib"
D:\myprogram\tt1.cpp:11:6: warning: integer constant is too large for its type

D:\myprogram\tt1.cpp: In function `int main()':
D:\myprogram\tt1.cpp:11: warning: this decimal constant is unsigned only in ISO C90
D:\myprogram\tt1.cpp:11: error: integer constant is too large for "long" type
D:\myprogram\tt1.cpp:11: error: ambiguous overload for 'operator=' in 'a = 0xa2a2282850abebbaull'
C:/Dev-Cpp/include/gmpxx.h:1605: note: candidates are: __gmp_expr<__mpz_struct[1], __mpz_struct[1]>& __gmp_expr<__mpz_struct[1], __mpz_struct[1]>::operator=(const __gmp_expr<__mpz_struct[1], __mpz_struct[1]>&)
C:/Dev-Cpp/include/gmpxx.h:1610: note:                 __gmp_expr<__mpz_struct[1], __mpz_struct[1]>& __gmp_expr<__mpz_struct[1], __mpz_struct[1]>::operator=(signed char)
C:/Dev-Cpp/include/gmpxx.h:1611: note:                 __gmp_expr<__mpz_struct[1], __mpz_struct[1]>& __gmp_expr<__mpz_struct[1], __mpz_struct[1]>::operator=(unsigned char)
C:/Dev-Cpp/include/gmpxx.h:1613: note:                 __gmp_expr<__mpz_struct[1], __mpz_struct[1]>& __gmp_expr<__mpz_struct[1], __mpz_struct[1]>::operator=(int)
C:/Dev-Cpp/include/gmpxx.h:1614: note:                 __gmp_expr<__mpz_struct[1], __mpz_struct[1]>& __gmp_expr<__mpz_struct[1], __mpz_struct[1]>::operator=(unsigned int)
C:/Dev-Cpp/include/gmpxx.h:1617: note:                 __gmp_expr<__mpz_struct[1], __mpz_struct[1]>& __gmp_expr<__mpz_struct[1], __mpz_struct[1]>::operator=(short int)
C:/Dev-Cpp/include/gmpxx.h:1619: note:                 __gmp_expr<__mpz_struct[1], __mpz_struct[1]>& __gmp_expr<__mpz_struct[1], __mpz_struct[1]>::operator=(short unsigned int)
C:/Dev-Cpp/include/gmpxx.h:1622: note:                 __gmp_expr<__mpz_struct[1], __mpz_struct[1]>& __gmp_expr<__mpz_struct[1], __mpz_struct[1]>::operator=(long int)
C:/Dev-Cpp/include/gmpxx.h:1624: note:                 __gmp_expr<__mpz_struct[1], __mpz_struct[1]>& __gmp_expr<__mpz_struct[1], __mpz_struct[1]>::operator=(long unsigned int)
C:/Dev-Cpp/include/gmpxx.h:1626: note:                 __gmp_expr<__mpz_struct[1], __mpz_struct[1]>& __gmp_expr<__mpz_struct[1], __mpz_struct[1]>::operator=(float)
C:/Dev-Cpp/include/gmpxx.h:1627: note:                 __gmp_expr<__mpz_struct[1], __mpz_struct[1]>& __gmp_expr<__mpz_struct[1], __mpz_struct[1]>::operator=(double)
C:/Dev-Cpp/include/gmpxx.h:1632: note:                 __gmp_expr<__mpz_struct[1], __mpz_struct[1]>& __gmp_expr<__mpz_struct[1], __mpz_struct[1]>::operator=(const char*) <near match>
C:/Dev-Cpp/include/gmpxx.h:1638: note:                 __gmp_expr<__mpz_struct[1], __mpz_struct[1]>& __gmp_expr<__mpz_struct[1], __mpz_struct[1]>::operator=(const std::string&) <near match>

Execution terminated

------------------------------------------
i am lost...
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
now, i have done the program. i am thanking you all for the helps, though i didnt get full answer, your ideas and direction has guided me to the one. i have  to split the points between your effort and my gain accordingly, i do hope it will satisfy everyone. cheers.