Skip to content

Latest commit

 

History

History
78 lines (44 loc) · 5.39 KB

CppApfloatExample2.md

File metadata and controls

78 lines (44 loc) · 5.39 KB

STL

Apfloat example 2 is an apfloat example.

Technical facts

Application type(s)

Operating system(s) or programming environment(s)

IDE(s):

Project type:

C++ standard:

Compiler(s):

Libraries used:

  • Qt Qt: version 5.4.1 (32 bit)
  • STL STL: GNU ISO C++ Library, version 4.9.2

 

 

 

 

 

Qt project file: ./CppApfloatExample2/CppApfloatExample2.pro

 


exists (../../ConsoleApplicationNoWeffcpp.pri) {   include(../../ConsoleApplicationNoWeffcpp.pri) } !exists (../../ConsoleApplication.pri) {   QT += core   QT += gui   greaterThan(QT_MAJOR_VERSION, 4): QT += widgets   CONFIG   += console   CONFIG   -= app_bundle   TEMPLATE = app   CONFIG(release, debug|release) {     DEFINES += NDEBUG NTRACE_BILDERBIKKEL   }   QMAKE_CXXFLAGS += -std=c++11 -Wall -Wextra   unix {     QMAKE_CXXFLAGS += -Werror   } } exists(../../Libraries/Boost.pri) {   include(../../Libraries/Boost.pri) } !exists(../../Libraries/Boost.pri) {   win32 {     INCLUDEPATH += \       ../../Libraries/boost_1_55_0   } } include(../../Libraries/Apfloat.pri) SOURCES += main.cpp

 

 

 

 

 

./CppApfloatExample2/main.cpp

 


#pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Weffc++" #pragma GCC diagnostic ignored "-Wunused-local-typedefs" #pragma GCC diagnostic ignored "-Wunused-variable" #include <iostream> #include <boost/lexical_cast.hpp> #include "apfloat.h" #pragma GCC diagnostic pop double ToDouble(const apfloat& a) {   std::stringstream s;   s << a;   double x = boost::lexical_cast<double>(s.str());   return x; } int main() {   const apfloat x = 1.0;   const double y = ToDouble(x);   const apfloat z = x;   assert(y == z);   std::cout     << x << '\n'     << y << '\n'     << z << '\n'   ; } /* Screen output 0.000000001e9 1 0.000000001e9 Press <RETURN> to close this window... */