23 #ifndef PLLL_INCLUDE_GUARD__ARITHMETIC_HPP
24 #define PLLL_INCLUDE_GUARD__ARITHMETIC_HPP
26 #include <plll/config.hpp>
67 namespace implementation
69 template<
typename A,
typename B,
typename Op>
82 template<
typename A,
typename B,
typename Op>
126 namespace implementation
128 template<
typename A,
typename Op>
141 template<
typename A,
typename Op>
196 is_cpp_string =
false,
199 has_uniform_rng =
true,
203 has_infinity =
false,
204 is_variable_precision =
false,
205 has_squareroot =
false,
206 has_full_power =
false,
207 has_special_fns =
false,
208 has_huge_exponent =
false,
209 has_constants =
false,
210 has_trigonometric =
false
228 is_cpp_string =
false,
231 has_uniform_rng =
true,
235 is_variable_precision =
true,
236 has_squareroot =
true,
237 has_full_power =
true,
238 has_special_fns =
true,
239 has_huge_exponent =
true,
240 has_constants =
true,
241 has_trigonometric =
true
259 is_cpp_string =
false,
262 has_uniform_rng =
false,
266 has_infinity =
false,
267 is_variable_precision =
false,
268 has_squareroot =
false,
269 has_full_power =
false,
270 has_special_fns =
false,
271 has_huge_exponent =
false,
272 has_constants =
false,
273 has_trigonometric =
false
276 typedef signed long PromoteType;
277 typedef signed int ConstReferenceType;
290 is_cpp_string =
false,
293 has_uniform_rng =
false,
297 has_infinity =
false,
298 is_variable_precision =
false,
299 has_squareroot =
false,
300 has_full_power =
false,
301 has_special_fns =
false,
302 has_huge_exponent =
false,
303 has_constants =
false,
304 has_trigonometric =
false
307 typedef unsigned long PromoteType;
308 typedef unsigned int ConstReferenceType;
321 is_cpp_string =
false,
324 has_uniform_rng =
false,
328 has_infinity =
false,
329 is_variable_precision =
false,
330 has_squareroot =
false,
331 has_full_power =
false,
332 has_special_fns =
false,
333 has_huge_exponent =
false,
334 has_constants =
false,
335 has_trigonometric =
false
338 typedef signed long PromoteType;
339 typedef signed long ConstReferenceType;
352 is_cpp_string =
false,
355 has_uniform_rng =
false,
359 has_infinity =
false,
360 is_variable_precision =
false,
361 has_squareroot =
false,
362 has_full_power =
false,
363 has_special_fns =
false,
364 has_huge_exponent =
false,
365 has_constants =
false,
366 has_trigonometric =
false
369 typedef unsigned long PromoteType;
370 typedef unsigned long ConstReferenceType;
383 is_cpp_string =
false,
386 has_uniform_rng =
false,
390 has_infinity =
false,
391 is_variable_precision =
false,
392 has_squareroot =
false,
393 has_full_power =
false,
394 has_special_fns =
false,
395 has_huge_exponent =
false,
396 has_constants =
false,
397 has_trigonometric =
false
400 typedef long long PromoteType;
401 typedef long long ConstReferenceType;
414 is_cpp_string =
false,
417 has_uniform_rng =
false,
421 is_variable_precision =
false,
422 has_squareroot =
true,
423 has_full_power =
true,
424 has_special_fns =
false,
425 has_huge_exponent =
false,
426 has_constants =
false,
427 has_trigonometric =
true
430 typedef double PromoteType;
431 typedef float ConstReferenceType;
444 is_cpp_string =
false,
447 has_uniform_rng =
false,
451 is_variable_precision =
false,
452 has_squareroot =
true,
453 has_full_power =
true,
454 has_special_fns =
false,
455 has_huge_exponent =
false,
456 has_constants =
false,
457 has_trigonometric =
true
460 typedef double PromoteType;
461 typedef double ConstReferenceType;
474 is_cpp_string =
false,
477 has_uniform_rng =
false,
481 is_variable_precision =
false,
482 has_squareroot =
true,
483 has_full_power =
true,
484 has_special_fns =
false,
485 has_huge_exponent =
false,
486 has_constants =
false,
487 has_trigonometric =
true
490 typedef long double PromoteType;
491 typedef long double ConstReferenceType;
507 is_cpp_string =
true,
523 is_cpp_string =
false,
537 is_cpp_string =
false,
551 is_cpp_string =
false,
565 is_cpp_string =
false,
571 using namespace traits;
573 namespace implementation
575 #define PLLL_INTERNAL_DEFINE_OPERATION(A, B, R) template<typename Op> struct binary_operation_impl<A, B, Op> \
576 { enum { supported = true, intermediate_expression = false }; typedef R ResultType; typedef R IntermediateType; }
578 PLLL_INTERNAL_DEFINE_OPERATION(
signed int,
signed int,
signed int );
579 PLLL_INTERNAL_DEFINE_OPERATION(
signed int,
unsigned int,
unsigned int );
580 PLLL_INTERNAL_DEFINE_OPERATION(
signed int,
signed long,
signed long );
581 PLLL_INTERNAL_DEFINE_OPERATION(
signed int,
unsigned long,
unsigned long);
582 PLLL_INTERNAL_DEFINE_OPERATION(
signed int,
long long,
long long );
583 PLLL_INTERNAL_DEFINE_OPERATION(
signed int,
float,
float );
584 PLLL_INTERNAL_DEFINE_OPERATION(
signed int,
double,
double );
585 PLLL_INTERNAL_DEFINE_OPERATION(
signed int,
long double,
long double );
587 PLLL_INTERNAL_DEFINE_OPERATION(
unsigned int,
signed int,
unsigned int );
588 PLLL_INTERNAL_DEFINE_OPERATION(
unsigned int,
unsigned int,
unsigned int );
589 PLLL_INTERNAL_DEFINE_OPERATION(
unsigned int,
signed long,
unsigned long);
590 PLLL_INTERNAL_DEFINE_OPERATION(
unsigned int,
unsigned long,
unsigned long);
591 PLLL_INTERNAL_DEFINE_OPERATION(
unsigned int,
long long,
long long );
592 PLLL_INTERNAL_DEFINE_OPERATION(
unsigned int,
float,
float );
593 PLLL_INTERNAL_DEFINE_OPERATION(
unsigned int,
double,
double );
594 PLLL_INTERNAL_DEFINE_OPERATION(
unsigned int,
long double,
long double );
596 PLLL_INTERNAL_DEFINE_OPERATION(
signed long,
signed int,
signed long );
597 PLLL_INTERNAL_DEFINE_OPERATION(
signed long,
unsigned int,
unsigned long);
598 PLLL_INTERNAL_DEFINE_OPERATION(
signed long,
signed long,
signed long );
599 PLLL_INTERNAL_DEFINE_OPERATION(
signed long,
unsigned long,
unsigned long);
600 PLLL_INTERNAL_DEFINE_OPERATION(
signed long,
long long,
long long );
601 PLLL_INTERNAL_DEFINE_OPERATION(
signed long,
float,
float );
602 PLLL_INTERNAL_DEFINE_OPERATION(
signed long,
double,
double );
603 PLLL_INTERNAL_DEFINE_OPERATION(
signed long,
long double,
long double );
605 PLLL_INTERNAL_DEFINE_OPERATION(
unsigned long,
signed int,
unsigned long);
606 PLLL_INTERNAL_DEFINE_OPERATION(
unsigned long,
unsigned int,
unsigned long);
607 PLLL_INTERNAL_DEFINE_OPERATION(
unsigned long,
signed long,
unsigned long);
608 PLLL_INTERNAL_DEFINE_OPERATION(
unsigned long,
unsigned long,
unsigned long);
609 PLLL_INTERNAL_DEFINE_OPERATION(
unsigned long,
long long,
long long );
610 PLLL_INTERNAL_DEFINE_OPERATION(
unsigned long,
float,
float );
611 PLLL_INTERNAL_DEFINE_OPERATION(
unsigned long,
double,
double );
612 PLLL_INTERNAL_DEFINE_OPERATION(
unsigned long,
long double,
long double );
614 PLLL_INTERNAL_DEFINE_OPERATION(
long long,
signed int,
long long );
615 PLLL_INTERNAL_DEFINE_OPERATION(
long long,
unsigned int,
long long );
616 PLLL_INTERNAL_DEFINE_OPERATION(
long long,
signed long,
long long );
617 PLLL_INTERNAL_DEFINE_OPERATION(
long long,
unsigned long,
long long );
618 PLLL_INTERNAL_DEFINE_OPERATION(
long long,
long long,
long long );
619 PLLL_INTERNAL_DEFINE_OPERATION(
long long,
float,
float );
620 PLLL_INTERNAL_DEFINE_OPERATION(
long long,
double,
double );
621 PLLL_INTERNAL_DEFINE_OPERATION(
long long,
long double,
long double);
623 PLLL_INTERNAL_DEFINE_OPERATION(
float,
signed int,
float );
624 PLLL_INTERNAL_DEFINE_OPERATION(
float,
unsigned int,
float );
625 PLLL_INTERNAL_DEFINE_OPERATION(
float,
signed long,
float );
626 PLLL_INTERNAL_DEFINE_OPERATION(
float,
unsigned long,
float );
627 PLLL_INTERNAL_DEFINE_OPERATION(
float,
long long,
float );
628 PLLL_INTERNAL_DEFINE_OPERATION(
float,
float,
float );
629 PLLL_INTERNAL_DEFINE_OPERATION(
float,
double,
double );
630 PLLL_INTERNAL_DEFINE_OPERATION(
float,
long double,
long double);
632 PLLL_INTERNAL_DEFINE_OPERATION(
double,
signed int,
double );
633 PLLL_INTERNAL_DEFINE_OPERATION(
double,
unsigned int,
double );
634 PLLL_INTERNAL_DEFINE_OPERATION(
double,
signed long,
double );
635 PLLL_INTERNAL_DEFINE_OPERATION(
double,
unsigned long,
double );
636 PLLL_INTERNAL_DEFINE_OPERATION(
double,
long long,
double );
637 PLLL_INTERNAL_DEFINE_OPERATION(
double,
float,
double );
638 PLLL_INTERNAL_DEFINE_OPERATION(
double,
double,
double );
639 PLLL_INTERNAL_DEFINE_OPERATION(
double,
long double,
long double);
641 PLLL_INTERNAL_DEFINE_OPERATION(
long double,
signed int,
long double);
642 PLLL_INTERNAL_DEFINE_OPERATION(
long double,
unsigned int,
long double);
643 PLLL_INTERNAL_DEFINE_OPERATION(
long double,
signed long,
long double);
644 PLLL_INTERNAL_DEFINE_OPERATION(
long double,
unsigned long,
long double);
645 PLLL_INTERNAL_DEFINE_OPERATION(
long double,
long long,
long double);
646 PLLL_INTERNAL_DEFINE_OPERATION(
long double,
float,
long double);
647 PLLL_INTERNAL_DEFINE_OPERATION(
long double,
double,
long double);
648 PLLL_INTERNAL_DEFINE_OPERATION(
long double,
long double,
long double);
649 #undef PLLL_INTERNAL_DEFINE_OPERATION
651 #define PLLL_INTERNAL_DEFINE_OPERATION(A, R) template<> struct unary_operation_impl<A, op::negation> \
652 { enum { supported = true, intermediate_expression = false }; typedef R ResultType; typedef R IntermediateType; }
653 PLLL_INTERNAL_DEFINE_OPERATION(
signed int,
signed int );
654 PLLL_INTERNAL_DEFINE_OPERATION(
unsigned int,
unsigned int );
655 PLLL_INTERNAL_DEFINE_OPERATION(
signed long,
signed long );
656 PLLL_INTERNAL_DEFINE_OPERATION(
unsigned long,
unsigned long);
657 PLLL_INTERNAL_DEFINE_OPERATION(
long long,
long long );
658 PLLL_INTERNAL_DEFINE_OPERATION(
float,
float );
659 PLLL_INTERNAL_DEFINE_OPERATION(
double,
double );
660 PLLL_INTERNAL_DEFINE_OPERATION(
long double,
long double );
661 #undef PLLL_INTERNAL_DEFINE_OPERATION
663 template<
class SourceType,
class DestContext>
720 template<
class SourceType,
class DestContext>
734 void convert(
typename DestContext::Type & dst,
const SourceType & src,
const DestContext & context)
739 template<
class SourceType,
class DestContext>
758 template<
class SourceType,
class DestContext>
774 void convert_fraction(
typename DestContext::Type & dst,
const SourceType & src1,
const SourceType & src2,
775 const DestContext & context)
781 template<
class SourceType,
class DestContext>
798 const DestContext & context)
804 template<
class SourceType,
class DestContext>
819 void convert_floor(
typename DestContext::Type & dst,
const SourceType & src,
const DestContext & context)
826 template<
class SourceType,
class DestContext>
848 template<
class SourceType,
class DestContext>
863 void convert_round(
typename DestContext::Type & dst,
const SourceType & src,
const DestContext & context)
870 template<
class SourceType,
class DestContext>
892 template<
class SourceType,
class DestContext>
909 void convert_round(
typename DestContext::Type & dst,
const SourceType & src,
bool & up,
const DestContext & context)
916 template<
class SourceType,
class DestContext>
940 template<
class SourceType,
class DestContext>
955 void convert_ceil(
typename DestContext::Type & dst,
const SourceType & src,
const DestContext & context)
962 template<
class SourceType,
class DestContext>
984 namespace implementation
986 template<
class SourceType>
996 template<
class Native,
class SourceType,
bool NativeInt,
bool SourceInt>
1018 template<
class Native,
class SourceType>
1038 template<
class Native,
class SourceType>
1039 typename implementation::nativeconversion_impl2<Native, SourceType, traits::type_traits<Native>::is_inttype || !traits::type_traits<Native>::is_number,
1040 traits::type_traits<SourceType>::is_inttype || !traits::type_traits<SourceType>::is_number>::RetVal_Floor
1060 template<
class Native,
class SourceType>
1072 typename implementation::nativeconversion_impl2<Native, SourceType, traits::type_traits<Native>::is_inttype || !traits::type_traits<Native>::is_number,
1073 traits::type_traits<SourceType>::is_inttype || !traits::type_traits<SourceType>::is_number>::RetVal_Round
1082 template<
class Native,
class SourceType>
1096 typename implementation::nativeconversion_impl2<Native, SourceType, traits::type_traits<Native>::is_inttype || !traits::type_traits<Native>::is_number,
1097 traits::type_traits<SourceType>::is_inttype || !traits::type_traits<SourceType>::is_number>::RetVal_Round2
1106 template<
class Native,
class SourceType>
1107 typename implementation::nativeconversion_impl2<Native, SourceType, traits::type_traits<Native>::is_inttype || !traits::type_traits<Native>::is_number,
1108 traits::type_traits<SourceType>::is_inttype || !traits::type_traits<SourceType>::is_number>::RetVal_Ceil
1152 enum { is_cputype =
false, is_realtype =
false, is_inttype =
false };
1214 namespace implementation
1216 template<
class SourceType,
bool SourceInt>
1225 typedef signed int RetVal;
1231 static RetVal
convert(
const SourceType & src)
1246 static RetVal_Round2
convert_round(
const SourceType & src,
bool & up)
1251 static RetVal_Ceil
convert_ceil(
const SourceType & src)
1257 template<
class SourceType,
bool SourceInt>
1269 typedef unsigned int RetVal;
1275 static RetVal
convert(
const SourceType & src)
1290 static RetVal_Round2
convert_round(
const SourceType & src,
bool & up)
1295 static RetVal_Ceil
convert_ceil(
const SourceType & src)
1301 template<
class SourceType,
bool SourceInt>
1313 typedef signed long RetVal;
1319 static RetVal
convert(
const SourceType & src)
1334 static RetVal_Round2
convert_round(
const SourceType & src,
bool & up)
1339 static RetVal_Ceil
convert_ceil(
const SourceType & src)
1345 template<
class SourceType,
bool SourceInt>
1357 typedef unsigned long RetVal;
1363 static unsigned long convert(
const SourceType & src)
1378 static RetVal_Round2
convert_round(
const SourceType & src,
bool & up)
1383 static RetVal_Ceil
convert_ceil(
const SourceType & src)
1389 template<
class SourceType,
bool SourceInt>
1401 typedef long long RetVal;
1407 static RetVal
convert(
const SourceType & src)
1422 static RetVal_Round2
convert_round(
const SourceType & src,
bool & up)
1427 static RetVal_Ceil
convert_ceil(
const SourceType & src)
1433 template<
class SourceType,
bool SourceInt>
1445 typedef float RetVal;
1446 typedef void RetVal_Floor;
1447 typedef void RetVal_Ceil;
1448 typedef void RetVal_Round;
1449 typedef void RetVal_Round2;
1451 static RetVal
convert(
const SourceType & src)
1457 template<
class SourceType,
bool SourceInt>
1466 typedef double RetVal;
1467 typedef void RetVal_Floor;
1468 typedef void RetVal_Ceil;
1469 typedef void RetVal_Round;
1470 typedef void RetVal_Round2;
1472 static RetVal
convert(
const SourceType & src)
1478 template<
class SourceType,
bool SourceInt>
1487 typedef long double RetVal;
1488 typedef void RetVal_Floor;
1489 typedef void RetVal_Ceil;
1490 typedef void RetVal_Round;
1491 typedef void RetVal_Round2;
1493 static RetVal
convert(
const SourceType & src)
1508 typedef const typename Context::Type & RetVal;
1510 typedef void RetVal_Floor;
1511 typedef void RetVal_Ceil;
1512 typedef void RetVal_Round;
1513 typedef void RetVal_Round2;
1515 static void convert(
typename Context::Type & d,
const typename Context::Type & v,
const Context & c)
1520 static RetVal
convert(
const typename Context::Type & v,
const Context & c)
1525 static void convert_frac(
typename Context::Type & d,
const typename Context::Type & v1,
const typename Context::Type & v2,
const Context & c)
1530 static RetVal_Frac convert_frac(
const typename Context::Type & v1,
const typename Context::Type & v2,
const Context & c)
1536 template<
class Context>
1563 template<
class Type>
1585 template<
class Context>
1593 typedef typename Context::Type RetVal1;
1594 typedef typename Context::Type RetVal2;
1596 static bool convert(
typename Context::Type & res,
const std::string & s,
const Context &)
1598 std::istringstream ss(s);
1603 static bool convert(
typename Context::Type & res,
const char * s,
const Context & c)
1605 std::istringstream ss(s);
1610 static RetVal1
convert(
const std::string & s,
const Context & c)
1617 static RetVal2
convert(
const char * s,
const Context & c)
1625 template<
class Type>
1626 class to_string_conversion
1633 typedef std::string RetVal;
1635 static RetVal
convert(
const Type & t)
1637 std::ostringstream ss;
1642 static RetVal
convert(
const Type & t,
unsigned base)
1644 std::ostringstream ss;
1645 ss << std::setbase(base) << t;
1649 static void convert(std::string & str,
const Type & t)
1651 std::ostringstream ss;
1656 static void convert(std::string & str,
const Type & t,
unsigned base)
1658 std::ostringstream ss;
1659 ss << std::setbase(base) << t;
1664 template<
class Type>
1673 typedef typename to_string_conversion<Type>::RetVal RetVal;
1674 typedef void RetVal_Floor;
1675 typedef void RetVal_Ceil;
1676 typedef void RetVal_Round;
1677 typedef void RetVal_Round2;
1690 template<
class Type>
1700 typedef typename to_string_conversion<Type>::RetVal RetVal;
1701 typedef void RetVal_Floor;
1702 typedef void RetVal_Ceil;
1703 typedef void RetVal_Round;
1704 typedef void RetVal_Round2;
1717 template<
class Type>
1727 typedef typename to_string_conversion<Type>::RetVal RetVal;
1728 typedef void RetVal_Floor;
1729 typedef void RetVal_Ceil;
1730 typedef void RetVal_Round;
1731 typedef void RetVal_Round2;
1744 template<
class Context>
1754 typedef typename from_string_conversion<Context>::RetVal1 RetVal;
1755 typedef void RetVal_Floor;
1756 typedef void RetVal_Ceil;
1757 typedef void RetVal_Round;
1758 typedef void RetVal_Round2;
1760 static void convert(
typename Context::Type & d,
const std::string & s,
const Context & c)
1765 static RetVal
convert(
const std::string & s,
const Context & c)
1771 template<
class Context>
1781 typedef typename from_string_conversion<Context>::RetVal2 RetVal;
1782 typedef void RetVal_Floor;
1783 typedef void RetVal_Ceil;
1784 typedef void RetVal_Round;
1785 typedef void RetVal_Round2;
1787 static inline void convert(
typename Context::Type & d,
const char * s,
const Context & c)
1792 static inline RetVal
convert(
const char * s,
const Context & c)
1798 template<
class Context>
1808 typedef typename from_string_conversion<Context>::RetVal2 RetVal;
1809 typedef void RetVal_Floor;
1810 typedef void RetVal_Ceil;
1811 typedef void RetVal_Round;
1812 typedef void RetVal_Round2;
1814 static inline void convert(
typename Context::Type & d,
char * s,
const Context & c)
1819 static inline RetVal
convert(
char * s,
const Context & c)
1825 template<
unsigned n,
class Context>
1835 typedef typename from_string_conversion<Context>::RetVal2 RetVal;
1836 typedef void RetVal_Floor;
1837 typedef void RetVal_Ceil;
1838 typedef void RetVal_Round;
1839 typedef void RetVal_Round2;
1841 static inline void convert(
typename Context::Type & d,
const char * s,
const Context & c)
1846 static inline RetVal
convert(
const char * s,
const Context & c)
1852 template<
unsigned n,
class Context>
1862 typedef typename from_string_conversion<Context>::RetVal2 RetVal;
1863 typedef void RetVal_Floor;
1864 typedef void RetVal_Ceil;
1865 typedef void RetVal_Round;
1866 typedef void RetVal_Round2;
1868 static inline void convert(
typename Context::Type & d,
const char * s,
const Context & c)
1873 static inline RetVal
convert(
const char * s,
const Context & c)
1879 template<
class SourceType,
bool SourceInt>
1889 typedef typename to_string_conversion<SourceType>::RetVal RetVal;
1890 typedef void RetVal_Floor;
1891 typedef void RetVal_Round;
1892 typedef void RetVal_Round2;
1893 typedef void RetVal_Ceil;
1895 static inline RetVal
convert(
const SourceType & v)
1910 static int toInt(
const std::string & v)
1912 std::istringstream s(v);
1918 static unsigned int toUInt(
const std::string & v)
1920 std::istringstream s(v);
1926 static long toLong(
const std::string & v)
1928 std::istringstream s(v);
1934 static long toULong(
const std::string & v)
1936 std::istringstream s(v);
1942 static long long toLongLong(
const std::string & v)
1944 std::istringstream s(v);
1950 static float toFloat(
const std::string & v)
1952 std::istringstream s(v);
1958 static double toDouble(
const std::string & v)
1960 std::istringstream s(v);
1966 static long double toLongDouble(
const std::string & v)
1968 std::istringstream s(v);
1984 static int toInt(
const char * v)
1986 std::istringstream s(v);
1992 static unsigned int toUInt(
const char * v)
1994 std::istringstream s(v);
2000 static long toLong(
const char * v)
2002 std::istringstream s(v);
2008 static unsigned long toULong(
const char * v)
2010 std::istringstream s(v);
2016 static long long toLongLong(
const char * v)
2018 std::istringstream s(v);
2024 static float toFloat(
const char * v)
2026 std::istringstream s(v);
2032 static double toDouble(
const char * v)
2034 std::istringstream s(v);
2040 static long double toLongDouble(
const char * v)
2042 std::istringstream s(v);
2058 static inline int toInt(
char * v)
2063 static inline unsigned int toUInt(
char * v)
2068 static inline long toLong(
char * v)
2073 static inline unsigned long toULong(
char * v)
2078 static inline long long toLongLong(
char * v)
2083 static inline float toFloat(
char * v)
2088 static inline double toDouble(
char * v)
2093 static inline long double toLongDouble(
char * v)
2108 static inline int toInt(
const char * v)
2113 static inline unsigned int toUInt(
const char * v)
2118 static inline long toLong(
const char * v)
2123 static inline unsigned long toULong(
const char * v)
2128 static inline long long toLongLong(
const char * v)
2133 static inline float toFloat(
const char * v)
2138 static inline double toDouble(
const char * v)
2143 static inline long double toLongDouble(
const char * v)
2158 static inline int toInt(
const char * v)
2163 static inline unsigned int toUInt(
const char * v)
2168 static inline long toLong(
const char * v)
2173 static inline unsigned long toULong(
const char * v)
2178 static inline long long toLongLong(
const char * v)
2183 static inline float toFloat(
const char * v)
2188 static inline double toDouble(
const char * v)
2193 static inline long double toLongDouble(
const char * v)
2206 namespace arithmetic
2208 namespace implementation
2210 extern IntegerContext g_intcontext;
2212 template<
class Source,
bool SourceInt>
2226 static RetVal
convert(
const Source & v)
2241 static RetVal_Round2
convert_round(
const Source & v,
bool & up)
Provides information on the result of an unary arithmetic operation.
implementation::binary_operation_impl< typename helper::remove_decorations< A >::Result, typename helper::remove_decorations< B >::Result, Op >::ResultType ResultType
StringContext(unsigned base)
Creates a string context for an arbitrary base.
#define PLLL_INTERNAL_STATIC_CHECK(condition, IdentifierWhichIsAMessage)
Provides information on the result of a binary arithmetic operation.
An "arithmetic" context for octal (base 8) conversions to std::strings.
An "arithmetic" context for conversions to std::strings.
implementation::nativeconversion_impl2< Native, SourceType, traits::type_traits< Native >::is_inttype||!traits::type_traits< Native >::is_number, traits::type_traits< SourceType >::is_inttype||!traits::type_traits< SourceType >::is_number >::RetVal convert(const SourceType &src)
Converts the value in src to the native type Native and returns the result.
Provides conversion implementation from type SourceType to DestContext::Type.
Provides information on the result of a binary arithmetic operation.
Provides information on the result of an unary arithmetic operation.
void convert(typename DestContext::Type &dst, const SourceType &src, const DestContext &context)
Converts the value in src to the type described by context and stores the result in dst...
Provides facilities to convert strings to types.
implementation::remove_decorations_impl< A >::result Result
The stripped type.
implementation::unary_operation_impl< typename helper::remove_decorations< typename MTIn::CoeffType_Get >::Result, arithmetic::op::negation >::IntermediateType IntermediateType
implementation::select_first_type_impl< cond, A, B >::result result
The result type. Either A or B, depending on the value of cond.
StringContext()
Creates a string context for base 10 (decimal).
implementation::binary_operation_impl< typename helper::remove_decorations< A >::Result, typename helper::remove_decorations< B >::Result, Op >::IntermediateType IntermediateType
Provides facilities to convert types to std::strings.
Implementation backend for conversions from context types to native types.
void convert_round(typename DestContext::Type &dst, const SourceType &src, const DestContext &context)
Converts the rounded value in src to the type described by context and stores the result in dst...
unsigned base() const
Queries the base of this context.
An "arithmetic" context for hexadecimal (base 16) conversions to std::strings.
Represents an arbitrary precision floating point value.
Header for arbitrary precision integer and floating point arithmetic, provided by GMP and MPFR...
void convert_fraction(typename DestContext::Type &dst, const SourceType &src1, const SourceType &src2, const DestContext &context)
Converts the values in src1 and scr2 to the type described by context and stores their quotient in ds...
Main header for arithmetic expressions.
Implementation backend for native conversion functions.
implementation::unary_operation_impl< typename helper::remove_decorations< typename MTIn::CoeffType_Get >::Result, arithmetic::op::negation >::ResultType ResultType
A type selector template.
void convert_floor(typename DestContext::Type &dst, const SourceType &src, const DestContext &context)
Converts the floor of the value in src to the type described by context and stores the result in dst...
void convert_ceil(typename DestContext::Type &dst, const SourceType &src, const DestContext &context)
Converts the ceil of the value in src to the type described by context and stores the result in dst...
std::string Type
The type.
Provides information on arithmetic (and string) types.
Represents an arbitrary precision integer.
Represents an arithmetic context for arbitrary precision integer.