Skip to content

Latest commit

 

History

History
134 lines (77 loc) · 3.86 KB

CppHelloGmp.md

File metadata and controls

134 lines (77 loc) · 3.86 KB

 

 

 

 

 

 

Hello GMP is an extension of Hello World. Like Hello World, Hello GMP is a simple console application. Hello GMP, however, also requires the GMP library and to link against it.

 

Here are some detailed examples of Hello GMP, depending on IDE and operating system:

 

 

 

 

 

 

Technical facts

 

Application type(s)

Operating system(s) or programming environment(s)

IDE(s):

Project type:

C++ standard:

Compiler(s):

Libraries used:

  • STL STL: GNU ISO C++ Library, version 4.7.2

 

 

 

 

 

Qt project file: CppHelloGmp.pro

 


QT       -= core gui TARGET = CppHelloGmp QMAKE_CXXFLAGS += -Wextra -Weffc++ -Werror unix:LIBS+= -L/usr/lib -lgmp CONFIG   += console CONFIG   -= app_bundle TEMPLATE = app SOURCES += main.cpp

 

 

 

 

 

main.cpp

 


#include <iostream> #include <gmpxx.h> ///From http://www.richelbilderbeek.nl/CppMpz_tToStr.htm const std::string Mpz_tToStr(const mpz_t& i) {   static char buffer[256];   mpz_get_str(buffer,10,i);   return std::string(buffer); } int main() {   mpz_t i;   mpz_init_set_str(i,"123456789012345678901234567890",10);   //Perform i = i * i   mpz_mul(i,i,i);   std::cout     << "Hello GMP,\n"     << Mpz_tToStr(i) << " times.\n";   mpz_clear(i); }