Go back to Richel Bilderbeek's homepage.

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

 

 

 

 

 

(C++) HfloatExample1

 

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: ./CppHfloatExample1/CppHfloatExample1.pro

 

exists (../../ConsoleApplication.pri) {
  include(../../ConsoleApplication.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 -Weffc++
  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/Hfloat.pri)

SOURCES += main.cpp

 

 

 

 

 

./CppHfloatExample1/main.cpp

 

#include <iostream>
#include "hfloat.h"

using namespace std;

int main()
{
  double x = 1.0;
  apfloat y = 1.0;
  for (int i=0; i!=20; ++i)
  {
    x /= 1.0e50;
    y /= 1.0e50;
    std::cout << x << " " << y << '\n';
  }
}

/* Screen output

1e-050 0.000009999999999999998550000e-45
1e-100 0.099999999999999971e-99
1e-150 0.000000999999999999999565000e-144
1e-200 0.009999999999999994200000000e-198
1e-250 0.000000099999999999999927500e-243
1e-300 0.000999999999999999130000000e-297
0 0.000000009999999999999989850e-342
0 0.000099999999999999884000000e-396
0 0.999999999999998695e-450
0 0.000009999999999999985500000e-495
0 0.099999999999999840500000000e-549
0 0.000000999999999999998260000e-594
0 0.009999999999999981150000000e-648
0 0.000000099999999999999797000e-693
0 0.000999999999999997825000000e-747
0 0.000000009999999999999976800e-792
0 0.000099999999999999753500000e-846
0 0.999999999999997390e-900
0 0.000009999999999999972450000e-945
0 0.099999999999999710e-999
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