Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) ApfloatExample2

 

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 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...

*/

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict

This page has been created by the tool CodeToHtml