Subject: [Boost-bugs] [Boost C++ Libraries] #9802: It seems as if integer division is being returned as a floating point
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-03-21 22:06:21
#9802: It seems as if integer division is being returned as a floating point
------------------------+------------------------------
Reporter: ajgibson@⦠| Type: Bugs
Status: new | Milestone: To Be Determined
Component: None | Version: Boost 1.55.0
Severity: Problem | Keywords:
------------------------+------------------------------
{{{
#include <iostream>
#include <boost/multiprecision/cpp_int.hpp>
int main()
{
const boost::multiprecision::cpp_int max = 6;
const boost::multiprecision::cpp_int factor = 4;
const boost::multiprecision::cpp_int result = factor * factor *
(max/factor);
std::cout << max << '/' << factor << " = " << max/factor << std::endl;
std::cout << result << std::endl;
const boost::multiprecision::cpp_int result2 = 4 * 4 * (6/4);
std::cout << result2 << std::endl;
}
---
6/4 = 1
24
16
}}}
The documentations states that the result of arithmetic is, "An
unmentionable-type expression template type when ExpressionTemplates is
true." The return type though seems questionable when doing integer
arithmetic it currently is returning floating point instead of integer
values. So for example when you do 6 / 4 you get 1.5 instead of 1.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/9802> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:15 UTC