From 2cfd31de4792e8c697f47e271597e2f740ac8b03 Mon Sep 17 00:00:00 2001 From: Roger Leigh Date: Mon, 22 Jun 2015 22:14:26 +0100 Subject: [PATCH] units: Improve precision of angle conversion Use high precision constants from boost/math/constants/constants.hpp to fix trac#6893. --- include/boost/units/base_units/angle/degree.hpp | 4 +++- include/boost/units/base_units/angle/gradian.hpp | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/include/boost/units/base_units/angle/degree.hpp b/include/boost/units/base_units/angle/degree.hpp index 63edb70e..4d2a9be0 100644 --- a/include/boost/units/base_units/angle/degree.hpp +++ b/include/boost/units/base_units/angle/degree.hpp @@ -11,10 +11,12 @@ #ifndef BOOST_UNITS_ANGLE_DEGREE_BASE_UNIT_HPP #define BOOST_UNITS_ANGLE_DEGREE_BASE_UNIT_HPP +#include + #include #include -BOOST_UNITS_DEFINE_BASE_UNIT_WITH_CONVERSIONS(angle,degree,"degree","deg",6.28318530718/360.,boost::units::angle::radian_base_unit,-101); +BOOST_UNITS_DEFINE_BASE_UNIT_WITH_CONVERSIONS(angle,degree,"degree","deg",boost::math::constants::degree(),boost::units::angle::radian_base_unit,-101); #if BOOST_UNITS_HAS_BOOST_TYPEOF diff --git a/include/boost/units/base_units/angle/gradian.hpp b/include/boost/units/base_units/angle/gradian.hpp index 7b291b46..7bd48adf 100644 --- a/include/boost/units/base_units/angle/gradian.hpp +++ b/include/boost/units/base_units/angle/gradian.hpp @@ -11,10 +11,12 @@ #ifndef BOOST_UNITS_ANGLE_GRADIAN_BASE_UNIT_HPP #define BOOST_UNITS_ANGLE_GRADIAN_BASE_UNIT_HPP +#include + #include #include -BOOST_UNITS_DEFINE_BASE_UNIT_WITH_CONVERSIONS(angle,gradian,"gradian","grad",6.28318530718/400.,boost::units::angle::radian_base_unit,-102); +BOOST_UNITS_DEFINE_BASE_UNIT_WITH_CONVERSIONS(angle,gradian,"gradian","grad",boost::math::constants::two_pi()/400.0,boost::units::angle::radian_base_unit,-102); #if BOOST_UNITS_HAS_BOOST_TYPEOF