Go back to Richel Bilderbeek's homepage.

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

 

 

 

 

 

(C++) StdRatioExample1

 

Technical facts

 

Operating system(s) or programming environment(s)

IDE(s):

Project type:

C++ standard:

Compiler(s):

Libraries used:

 

 

 

 

 

Qt project file: ./CppStdRatioExample1/CppStdRatioExample1.pro

 

TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
QMAKE_CXXFLAGS += -std=c++11 -Wall -Wextra -Weffc++ -Werror
SOURCES += main.cpp

 

 

 

 

 

./CppStdRatioExample1/main.cpp

 

#include <iostream>
#include <ratio>

int main()
{
  static_assert(std::ratio<7,-21>::num == -1,
    "std::ratio simplifies, takes sign to numerator");
  static_assert(std::ratio<7,-21>::den ==  3,
    "std::ratio simplifies, takes sign to numerator");

  static_assert(std::ratio_add<std::ratio<1,3>,std::ratio<1,6>>::num == 1,"1/3 + 1/6 == 1/2");
  static_assert(std::ratio_add<std::ratio<1,3>,std::ratio<1,6>>::den == 2,"1/3 + 1/6 == 1/2");
}

 

 

 

 

 

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