diff --git a/doc/html/boost_multiprecision/indexes/s01.html b/doc/html/boost_multiprecision/indexes/s01.html index b8cec282..d414d97f 100644 --- a/doc/html/boost_multiprecision/indexes/s01.html +++ b/doc/html/boost_multiprecision/indexes/s01.html @@ -13,13 +13,20 @@
PrevUpHomeNext
-
+

-Function Index

-

B C D E F I L M P R S T Z

+Function Index
+

A B C D E F I L M P R S T Z

-B +A +
+
+
+B
  • @@ -40,14 +47,14 @@
-C +C
-D +D
  • @@ -69,21 +76,246 @@
-E +E
-
-F +F
-I +I
  • @@ -120,7 +352,7 @@
-L +L
  • @@ -145,7 +377,7 @@
-M +M
  • miller_rabin_test

    @@ -155,7 +387,7 @@
-P +P
-R +R
-S +S
-T +T
-Z +Z
+

C G M N T

-C +C
  • @@ -33,7 +33,7 @@
-G +G
-M +M
  • mpfr_float_backend

    @@ -51,7 +51,7 @@
-N +N
-T +T
+

C I L M T U

-C +C
  • @@ -47,7 +47,7 @@
-I +I
  • @@ -72,14 +72,14 @@
-L +L
-M +M
  • @@ -154,7 +154,7 @@
-T +T
-U +U
  • diff --git a/doc/html/boost_multiprecision/indexes/s04.html b/doc/html/boost_multiprecision/indexes/s04.html index 7d33939b..50d6b336 100644 --- a/doc/html/boost_multiprecision/indexes/s04.html +++ b/doc/html/boost_multiprecision/indexes/s04.html @@ -12,13 +12,20 @@
    PrevUpHome
    -
    +

    -Index

    -

    B C D E F G I L M N O P R S T U Z

    +Index
+

A B C D E F G I L M N O P R S T U Z

-B +A +
+
+
+B
  • @@ -43,7 +50,7 @@
-C +C
-D +D
  • @@ -135,21 +163,246 @@
-E +E
-
-F +F
-G +G
  • @@ -185,7 +438,7 @@
-I +I
  • @@ -246,7 +499,7 @@
-L +L
  • @@ -275,7 +528,7 @@
-M +M
  • @@ -373,7 +626,7 @@
-N +N
  • @@ -417,14 +670,59 @@
-O +O
-P +P
  • @@ -452,7 +750,7 @@
-R +R
  • @@ -465,7 +763,7 @@
-S +S
  • @@ -478,7 +776,7 @@
-T +T
  • @@ -511,7 +809,7 @@
-U +U
  • @@ -532,7 +830,7 @@
-Z +Z
@@ -759,6 +949,7 @@ + @@ -776,9 +967,101 @@ Comments

+ +

+ Throws +

+ + +

+ Construct and assign: +

+ +  +  +  + + + +

+ B(rb) +

+ + +

+ B +

+ + +

+ Move constructor. Afterwards variable rb + shall be in sane state, albeit with unspecified value. Only destruction + and assignment to the moved-from variable rb + need be supported after the operation. +

+ + +

+ noexcept +

+ + + + +

+ b = + rb +

+ + +

+ B& +

+ + +

+ Move-assign. Afterwards variable rb + shall be in sane state, albeit with unspecified value. Only destruction + and assignment to the moved-from variable rb + need be supported after the operation. +

+ + +

+ noexcept +

+ + + + +

+ B(a) +

+ + +

+ B +

+ + +

+ Direct construction from an arithmetic type. The type of a shall be listed in one of the + type lists B::signed_types, B::unsigned_types + or B::float_types. When not provided, + this operation is simulated using default-construction followed + by assignment. +

+ + +

+   +

+ + +

B(b2) @@ -791,7 +1074,13 @@

- Copy constructor from a different back-end type. + Copy constructor from a different back-end type. When not provided, + a generic interconversion routine is used. +

+ + +

+  

@@ -809,7 +1098,13 @@

- Assignment operator from a different back-end type. + Assignment operator from a different back-end type. When not provided, + a generic interconversion routine is used. +

+ + +

+  

@@ -828,7 +1123,13 @@

Assigns to b the two components in the following arguments. Only applies to rational - and complex number types. + and complex number types. When not provided, arithmetic operations + are used to synthesise the result from the two values. +

+ + +

+  

@@ -847,9 +1148,324 @@

Assigns to b the two components in the following arguments. Only applies to rational - and complex number types. + and complex number types. When not provided, arithmetic operations + are used to synthesise the result from the two values.

+ +

+   +

+ + + + +

+ Comparisons: +

+ +  +  +  + + + +

+ eval_eq(cb, + cb2) +

+ + +

+ bool +

+ + +

+ Returns true if cb and cb2 + are equal in value. When not provided, the default implementation + returns cb.compare(cb2) + == 0. +

+ + +

+ noexcept +

+ + + + +

+ eval_eq(cb, + a) +

+ + +

+ bool +

+ + +

+ Returns true if cb and a + are equal in value. The type of a + shall be listed in one of the type lists B::signed_types, + B::unsigned_types or B::float_types. When not provided, + return the equivalent of eval_eq(cb, B(a)). +

+ + +

+   +

+ + + + +

+ eval_eq(a, + cb) +

+ + +

+ bool +

+ + +

+ Returns true if cb and a + are equal in value. The type of a + shall be listed in one of the type lists B::signed_types, + B::unsigned_types or B::float_types. When not provided, + the default version returns eval_eq(cb, a). +

+ + +

+   +

+ + + + +

+ eval_lt(cb, + cb2) +

+ + +

+ bool +

+ + +

+ Returns true if cb is less than cb2 in value. When not provided, + the default implementation returns cb.compare(cb2) < + 0. +

+ + +

+ noexcept +

+ + + + +

+ eval_lt(cb, + a) +

+ + +

+ bool +

+ + +

+ Returns true if cb is less than a in value. The type of a shall be listed in one of the + type lists B::signed_types, B::unsigned_types + or B::float_types. When not provided, + the default implementation returns eval_lt(cb, B(a)). +

+ + +

+   +

+ + + + +

+ eval_lt(a, + cb) +

+ + +

+ bool +

+ + +

+ Returns true if a is less than cb in value. The type of a shall be listed in one of the + type lists B::signed_types, B::unsigned_types + or B::float_types. When not provided, + the default implementation returns eval_gt(cb, a). +

+ + +

+   +

+ + + + +

+ eval_gt(cb, + cb2) +

+ + +

+ bool +

+ + +

+ Returns true if cb is greater than cb2 in value. When not provided, + the default implementation returns cb.compare(cb2) > + 0. +

+ + +

+ noexcept +

+ + + + +

+ eval_gt(cb, + a) +

+ + +

+ bool +

+ + +

+ Returns true if cb is greater than a in value. The type of a shall be listed in one of the + type lists B::signed_types, B::unsigned_types + or B::float_types. When not provided, + the default implementation returns eval_gt(cb, B(a)). +

+ + +

+   +

+ + + + +

+ eval_gt(a, + cb) +

+ + +

+ bool +

+ + +

+ Returns true if a is greater than cb in value. The type of a shall be listed in one of the + type lists B::signed_types, B::unsigned_types + or B::float_types. When not provided, + the default implementation returns eval_lt(cb, a). +

+ + +

+   +

+ + + + +

+ eval_is_zero(cb) +

+ + +

+ bool +

+ + +

+ Returns true if cb is zero, otherwise false. The default version of this + function returns cb.compare(ui_type(0)) == + 0, where ui_type + is ui_type is + typename mpl::front<typename + B::unsigned_types>::type. +

+ + +

+   +

+ + + + +

+ eval_get_sign(cb) +

+ + +

+ int +

+ + +

+ Returns a value < zero if cb + is negative, a value > zero if cb + is positive, and zero if cb + is zero. The default version of this function returns cb.compare(ui_type(0)), + where ui_type is + ui_type is typename mpl::front<typename + B::unsigned_types>::type. +

+ + +

+   +

+ + + + +

+ Basic arithmetic: +

+ +  +  +  @@ -867,160 +1483,13 @@

Adds a to b. The type of a shall be listed in one of the type lists B::signed_types, B::unsigned_types - or B::float_types. -

- - - - -

- eval_subtract(b, - a) + or B::float_types. When not provided, + the default version calls eval_add(b, B(a))

- void -

- - -

- Subtracts a from - b. The type of - a shall be listed - in one of the type lists B::signed_types, - B::unsigned_types or B::float_types. -

- - - - -

- eval_multiply(b, - a) -

- - -

- void -

- - -

- Multiplies b by - a. The type of - a shall be listed - in one of the type lists B::signed_types, - B::unsigned_types or B::float_types. -

- - - - -

- eval_divide(b, - a) -

- - -

- void -

- - -

- Divides b by a. The type of a shall be listed in one of the - type lists B::signed_types, B::unsigned_types - or B::float_types. -

- - - - -

- eval_modulus(b, - a) -

- - -

- void -

- - -

- Computes b %= - cb, only required when - B is an integer - type. The type of a - shall be listed in one of the type lists B::signed_types, - B::unsigned_types or B::float_types. -

- - - - -

- eval_bitwise_and(b, a) -

- - -

- void -

- - -

- Computes b &= - cb, only required when - B is an integer - type. The type of a - shall be listed in one of the type lists B::signed_types, - B::unsigned_types or B::float_types. -

- - - - -

- eval_bitwise_or(b, a) -

- - -

- void -

- - -

- Computes b |= - cb, only required when - B is an integer - type. The type of a - shall be listed in one of the type lists B::signed_types, - B::unsigned_types or B::float_types. -

- - - - -

- eval_bitwise_xor(b, a) -

- - -

- void -

- - -

- Computes b ^= - cb, only required when - B is an integer - type. The type of a - shall be listed in one of the type lists B::signed_types, - B::unsigned_types or B::float_types. +  

@@ -1040,70 +1509,14 @@

Add cb to cb2 and stores the result in - b. -

- - - - -

- eval_subtract(b, - cb, - cb2) + b. When not provided, + does the equivalent of b + = cb; eval_add(b, cb2).

- void -

- - -

- Subtracts cb2 from - cb and stores the - result in b. -

- - - - -

- eval_multiply(b, - cb, - cb2) -

- - -

- void -

- - -

- Multiplies cb by - cb2 and stores - the result in b. -

- - - - -

- eval_divide(b, - cb, - cb2) -

- - -

- void -

- - -

- Divides cb by - cb2 and stores - the result in b. +  

@@ -1124,165 +1537,13 @@

Add cb to a and stores the result in b. The type of a shall be listed in one of the type lists B::signed_types, B::unsigned_types - or B::float_types. -

- - - - -

- eval_subtract(b, - cb, - a) + or B::float_types. When not provided, + does the equivalent of eval_add(b, cb, B(a)).

- void -

- - -

- Subtracts a from - cb and stores the - result in b. The - type of a shall - be listed in one of the type lists B::signed_types, - B::unsigned_types or B::float_types. -

- - - - -

- eval_multiply(b, - cb, - a) -

- - -

- void -

- - -

- Multiplies cb by - a and stores the - result in b. The - type of a shall - be listed in one of the type lists B::signed_types, - B::unsigned_types or B::float_types. -

- - - - -

- eval_divide(b, - cb, - a) -

- - -

- void -

- - -

- Divides cb by - a and stores the - result in b. The - type of a shall - be listed in one of the type lists B::signed_types, - B::unsigned_types or B::float_types. -

- - - - -

- eval_modulus(b, - cb, - cb2) -

- - -

- void -

- - -

- Computes cb % - cb2 and stores the result - in b, only required - when B is an integer - type. -

- - - - -

- eval_bitwise_and(b, cb, cb2) -

- - -

- void -

- - -

- Computes cb & - cb2 and stores the result - in b, only required - when B is an integer - type. -

- - - - -

- eval_bitwise_or(b, cb, cb2) -

- - -

- void -

- - -

- Computes cb | - cb2 and stores the result - in b, only required - when B is an integer - type. -

- - - - -

- eval_bitwise_xor(b, cb, cb2) -

- - -

- void -

- - -

- Computes cb ^ - cb2 and stores the result - in b, only required - when B is an integer - type. +  

@@ -1305,7 +1566,99 @@ b. The type of a shall be listed in one of the type lists B::signed_types, - B::unsigned_types or B::float_types. + B::unsigned_types or B::float_types. When not provided, + does the equivalent of eval_add(b, cb, a). +

+ + +

+   +

+ + + + +

+ eval_subtract(b, + a) +

+ + +

+ void +

+ + +

+ Subtracts a from + b. The type of + a shall be listed + in one of the type lists B::signed_types, + B::unsigned_types or B::float_types. When not provided, + the default version calls eval_subtract(b, B(a)) +

+ + +

+   +

+ + + + +

+ eval_subtract(b, + cb, + cb2) +

+ + +

+ void +

+ + +

+ Subtracts cb2 from + cb and stores the + result in b. When + not provided, does the equivalent of b + = cb; eval_subtract(b, cb2). +

+ + +

+   +

+ + + + +

+ eval_subtract(b, + cb, + a) +

+ + +

+ void +

+ + +

+ Subtracts a from + cb and stores the + result in b. The + type of a shall + be listed in one of the type lists B::signed_types, + B::unsigned_types or B::float_types. When not provided, + does the equivalent of eval_subtract(b, cb, B(a)). +

+ + +

+  

@@ -1329,7 +1682,99 @@ result in b. The type of a shall be listed in one of the type lists B::signed_types, - B::unsigned_types or B::float_types. + B::unsigned_types or B::float_types. When not provided, + does the equivalent of eval_subtract(b, cb, a); b.negate();. +

+ + +

+   +

+ + + + +

+ eval_multiply(b, + a) +

+ + +

+ void +

+ + +

+ Multiplies b by + a. The type of + a shall be listed + in one of the type lists B::signed_types, + B::unsigned_types or B::float_types. When not provided, + the default version calls eval_multiply(b, B(a)) +

+ + +

+   +

+ + + + +

+ eval_multiply(b, + cb, + cb2) +

+ + +

+ void +

+ + +

+ Multiplies cb by + cb2 and stores + the result in b. + When not provided, does the equivalent of b + = cb; eval_multiply(b, cb2). +

+ + +

+   +

+ + + + +

+ eval_multiply(b, + cb, + a) +

+ + +

+ void +

+ + +

+ Multiplies cb by + a and stores the + result in b. The + type of a shall + be listed in one of the type lists B::signed_types, + B::unsigned_types or B::float_types. When not provided, + does the equivalent of eval_multiply(b, cb, B(a)). +

+ + +

+  

@@ -1353,7 +1798,104 @@ result in b. The type of a shall be listed in one of the type lists B::signed_types, - B::unsigned_types or B::float_types. + B::unsigned_types or B::float_types. When not provided, + does the equivalent of eval_multiply(b, cb, a). +

+ + +

+   +

+ + + + +

+ eval_divide(b, + a) +

+ + +

+ void +

+ + +

+ Divides b by a. The type of a shall be listed in one of the + type lists B::signed_types, B::unsigned_types + or B::float_types. When not provided, + the default version calls eval_divide(b, B(a)) +

+ + +

+ std::overflow_error if a has the value zero, and std::numeric_limits<number<B> + >::has_infinity + == false +

+ + + + +

+ eval_divide(b, + cb, + cb2) +

+ + +

+ void +

+ + +

+ Divides cb by + cb2 and stores + the result in b. + When not provided, does the equivalent of b + = cb; eval_divide(b, cb2). +

+ + +

+ std::overflow_error if cb2 has the value zero, and + std::numeric_limits<number<B> + >::has_infinity + == false +

+ + + + +

+ eval_divide(b, + cb, + a) +

+ + +

+ void +

+ + +

+ Divides cb by + a and stores the + result in b. The + type of a shall + be listed in one of the type lists B::signed_types, + B::unsigned_types or B::float_types. When not provided, + does the equivalent of eval_divide(b, cb, B(a)). +

+ + +

+ std::overflow_error if a has the value zero, and std::numeric_limits<number<B> + >::has_infinity + == false

@@ -1376,7 +1918,137 @@ b. The type of a shall be listed in one of the type lists B::signed_types, - B::unsigned_types or B::float_types. + B::unsigned_types or B::float_types. When not provided, + does the equivalent of eval_divide(b, B(a), cb). +

+ + +

+ std::overflow_error if cb has the + value zero, and std::numeric_limits<number<B> >::has_infinity == + false +

+ + + + +

+ eval_increment(b) +

+ + +

+ void +

+ + +

+ Increments the value of b + by one. When not provided, does the equivalent of eval_add(b, + static_cast<ui_type>(1u)). + Where ui_type is + typename mpl::front<typename + B::unsigned_types>::type. +

+ + +

+   +

+ + + + +

+ eval_decrement(b) +

+ + +

+ void +

+ + +

+ Decrements the value of b + by one. When not provided, does the equivalent of eval_subtract(b, + static_cast<ui_type>(1u)). + Where ui_type is + typename mpl::front<typename + B::unsigned_types>::type. +

+ + +

+   +

+ + + + +

+ Integer specific operations: +

+ +  +  +  + + + +

+ eval_modulus(b, + a) +

+ + +

+ void +

+ + +

+ Computes b %= + cb, only required when + B is an integer + type. The type of a + shall be listed in one of the type lists B::signed_types, + B::unsigned_types or B::float_types. When not provided, + the default version calls eval_modulus(b, B(a)) +

+ + +

+ std::overflow_error if a has the value zero. +

+ + + + +

+ eval_modulus(b, + cb, + cb2) +

+ + +

+ void +

+ + +

+ Computes cb % + cb2 and stores the result + in b, only required + when B is an integer + type. When not provided, does the equivalent of b + = cb; eval_modulus(b, cb2). +

+ + +

+ std::overflow_error if a has the value zero.

@@ -1401,76 +2073,13 @@ when B is an integer type. The type of a shall be listed in one of the type lists B::signed_types, - B::unsigned_types or B::float_types. -

- - - - -

- eval_bitwise_and(b, cb, a) + B::unsigned_types or B::float_types. When not provided, + does the equivalent of eval_modulus(b, cb, B(a)).

- void -

- - -

- Computes cb & - a and stores the result - in b, only required - when B is an integer - type. The type of a - shall be listed in one of the type lists B::signed_types, - B::unsigned_types or B::float_types. -

- - - - -

- eval_bitwise_or(b, cb, a) -

- - -

- void -

- - -

- Computes cb | - a and stores the result - in b, only required - when B is an integer - type. The type of a - shall be listed in one of the type lists B::signed_types, - B::unsigned_types or B::float_types. -

- - - - -

- eval_bitwise_xor(b, cb, a) -

- - -

- void -

- - -

- Computes cb ^ - a and stores the result - in b, only required - when B is an integer - type. The type of a - shall be listed in one of the type lists B::signed_types, - B::unsigned_types or B::float_types. + std::overflow_error if a has the value zero.

@@ -1495,7 +2104,97 @@ when B is an integer type. The type of a shall be listed in one of the type lists B::signed_types, - B::unsigned_types or B::float_types. + B::unsigned_types or B::float_types. When not provided, + does the equivalent of eval_modulus(b, B(a), cb). +

+ + +

+ std::overflow_error if a has the value zero. +

+ + + + +

+ eval_bitwise_and(b, a) +

+ + +

+ void +

+ + +

+ Computes b &= + cb, only required when + B is an integer + type. The type of a + shall be listed in one of the type lists B::signed_types, + B::unsigned_types or B::float_types. When not provided, + the default version calls eval_bitwise_and(b, B(a)) +

+ + +

+   +

+ + + + +

+ eval_bitwise_and(b, cb, cb2) +

+ + +

+ void +

+ + +

+ Computes cb & + cb2 and stores the result + in b, only required + when B is an integer + type. When not provided, does the equivalent of b + = cb; eval_bitwise_and(b, cb2). +

+ + +

+   +

+ + + + +

+ eval_bitwise_and(b, cb, a) +

+ + +

+ void +

+ + +

+ Computes cb & + a and stores the result + in b, only required + when B is an integer + type. The type of a + shall be listed in one of the type lists B::signed_types, + B::unsigned_types or B::float_types. When not provided, + does the equivalent of eval_bitwise_and(b, cb, B(a)). +

+ + +

+  

@@ -1518,7 +2217,97 @@ when B is an integer type. The type of a shall be listed in one of the type lists B::signed_types, - B::unsigned_types or B::float_types. + B::unsigned_types or B::float_types. When not provided, + does the equivalent of eval_bitwise_and(b, cb, a). +

+ + +

+   +

+ + + + +

+ eval_bitwise_or(b, a) +

+ + +

+ void +

+ + +

+ Computes b |= + cb, only required when + B is an integer + type. The type of a + shall be listed in one of the type lists B::signed_types, + B::unsigned_types or B::float_types. When not provided, + the default version calls eval_bitwise_or(b, B(a)) +

+ + +

+   +

+ + + + +

+ eval_bitwise_or(b, cb, cb2) +

+ + +

+ void +

+ + +

+ Computes cb | + cb2 and stores the result + in b, only required + when B is an integer + type. When not provided, does the equivalent of b + = cb; eval_bitwise_or(b, cb2). +

+ + +

+   +

+ + + + +

+ eval_bitwise_or(b, cb, a) +

+ + +

+ void +

+ + +

+ Computes cb | + a and stores the result + in b, only required + when B is an integer + type. The type of a + shall be listed in one of the type lists B::signed_types, + B::unsigned_types or B::float_types. When not provided, + does the equivalent of eval_bitwise_or(b, cb, B(a)). +

+ + +

+  

@@ -1541,7 +2330,97 @@ when B is an integer type. The type of a shall be listed in one of the type lists B::signed_types, - B::unsigned_types or B::float_types. + B::unsigned_types or B::float_types. When not provided, + does the equivalent of eval_bitwise_or(b, cb, a). +

+ + +

+   +

+ + + + +

+ eval_bitwise_xor(b, a) +

+ + +

+ void +

+ + +

+ Computes b ^= + cb, only required when + B is an integer + type. The type of a + shall be listed in one of the type lists B::signed_types, + B::unsigned_types or B::float_types. When not provided, + the default version calls eval_bitwise_xor(b, B(a)) +

+ + +

+   +

+ + + + +

+ eval_bitwise_xor(b, cb, cb2) +

+ + +

+ void +

+ + +

+ Computes cb ^ + cb2 and stores the result + in b, only required + when B is an integer + type. When not provided, does the equivalent of b + = cb; eval_bitwise_xor(b, cb2). +

+ + +

+   +

+ + + + +

+ eval_bitwise_xor(b, cb, a) +

+ + +

+ void +

+ + +

+ Computes cb ^ + a and stores the result + in b, only required + when B is an integer + type. The type of a + shall be listed in one of the type lists B::signed_types, + B::unsigned_types or B::float_types. When not provided, + does the equivalent of eval_bitwise_xor(b, cb, B(a)). +

+ + +

+  

@@ -1564,7 +2443,13 @@ when B is an integer type. The type of a shall be listed in one of the type lists B::signed_types, - B::unsigned_types or B::float_types. + B::unsigned_types or B::float_types. When not provided, + does the equivalent of eval_bitwise_xor(b, cb, a). +

+ + +

+  

@@ -1585,7 +2470,13 @@ ui and stores the result in b, only required when B is an integer - type. + type. When not provided, does the equivalent of b + = cb; eval_left_shift(b, a);. +

+ + +

+  

@@ -1606,517 +2497,13 @@ ui and stores the result in b, only required when B is an integer - type. + type. When not provided, does the equivalent of b + = cb; eval_right_shift(b, a);.

- -

- eval_increment(b) -

- - -

- void -

- - -

- Increments the value of b - by one. -

- - - - -

- eval_decrement(b) -

- - -

- void -

- - -

- Decrements the value of b - by one. -

- - - - -

- eval_is_zero(cb) -

- - -

- bool -

- - -

- Returns true if cb is zero, otherwise false -

- - - - -

- eval_get_sign(cb) -

- - -

- int -

- - -

- Returns a value < zero if cb - is negative, a value > zero if cb - is positive, and zero if cb - is zero. -

- - - - -

- eval_abs(b, - cb) -

- - -

- void -

- - -

- Set b to the absolute - value of cb. -

- - - - -

- eval_fabs(b, - cb) -

- - -

- void -

- - -

- Set b to the absolute - value of cb. -

- - - - -

- eval_fpclassify(cb) -

- - -

- int -

- - -

- Returns one of the same values returned by std::fpclassify. - Only required when B - is an floating-point type. -

- - - - -

- eval_trunc(b, - cb) -

- - -

- void -

- - -

- Performs the equivalent operation to std::trunc - on argument cb - and stores the result in b. - Only required when B - is an floating-point type. -

- - - - -

- eval_round(b, - cb) -

- - -

- void -

- - -

- Performs the equivalent operation to std::round - on argument cb - and stores the result in b. - Only required when B - is an floating-point type. -

- - - - -

- eval_exp(b, - cb) -

- - -

- void -

- - -

- Performs the equivalent operation to std::exp - on argument cb - and stores the result in b. - Only required when B - is an floating-point type. -

- - - - -

- eval_log(b, - cb) -

- - -

- void -

- - -

- Performs the equivalent operation to std::log - on argument cb - and stores the result in b. - Only required when B - is an floating-point type. -

- - - - -

- eval_log10(b, - cb) -

- - -

- void -

- - -

- Performs the equivalent operation to std::log10 - on argument cb - and stores the result in b. - Only required when B - is an floating-point type. -

- - - - -

- eval_sin(b, - cb) -

- - -

- void -

- - -

- Performs the equivalent operation to std::sin - on argument cb - and stores the result in b. - Only required when B - is an floating-point type. -

- - - - -

- eval_cos(b, - cb) -

- - -

- void -

- - -

- Performs the equivalent operation to std::cos - on argument cb - and stores the result in b. - Only required when B - is an floating-point type. -

- - - - -

- eval_tan(b, - cb) -

- - -

- void -

- - -

- Performs the equivalent operation to std::exp - on argument cb - and stores the result in b. - Only required when B - is an floating-point type. -

- - - - -

- eval_asin(b, - cb) -

- - -

- void -

- - -

- Performs the equivalent operation to std::asin - on argument cb - and stores the result in b. - Only required when B - is an floating-point type. -

- - - - -

- eval_acos(b, - cb) -

- - -

- void -

- - -

- Performs the equivalent operation to std::acos - on argument cb - and stores the result in b. - Only required when B - is an floating-point type. -

- - - - -

- eval_atan(b, - cb) -

- - -

- void -

- - -

- Performs the equivalent operation to std::atan - on argument cb - and stores the result in b. - Only required when B - is an floating-point type. -

- - - - -

- eval_sinh(b, - cb) -

- - -

- void -

- - -

- Performs the equivalent operation to std::sinh - on argument cb - and stores the result in b. - Only required when B - is an floating-point type. -

- - - - -

- eval_cosh(b, - cb) -

- - -

- void -

- - -

- Performs the equivalent operation to std::cosh - on argument cb - and stores the result in b. - Only required when B - is an floating-point type. -

- - - - -

- eval_tanh(b, - cb) -

- - -

- void -

- - -

- Performs the equivalent operation to std::tanh - on argument cb - and stores the result in b. - Only required when B - is an floating-point type. -

- - - - -

- eval_fmod(b, - cb, - cb2) -

- - -

- void -

- - -

- Performs the equivalent operation to std::fmod - on arguments cb - and cb2, and store - the result in b. - Only required when B - is an floating-point type. -

- - - - -

- eval_pow(b, - cb, - cb2) -

- - -

- void -

- - -

- Performs the equivalent operation to std::pow - on arguments cb - and cb2, and store - the result in b. - Only required when B - is an floating-point type. -

- - - - -

- eval_atan2(b, - cb, - cb2) -

- - -

- void -

- - -

- Performs the equivalent operation to std::atan - on arguments cb - and cb2, and store - the result in b. - Only required when B - is an floating-point type. +  

@@ -2141,7 +2528,13 @@ cb2 and b2 to the result of cb % cb2. Only required when B is an integer - type. + type. The default version of this function is synthesised from + other operations above. +

+ + +

+ std::overflow_error if a has the value zero.

@@ -2161,7 +2554,13 @@ Returns the result of cb % ui. Only required when B - is an integer type. + is an integer type. The default version of this function is synthesised + from other operations above. +

+ + +

+ std::overflow_error if a has the value zero.

@@ -2180,7 +2579,13 @@

Returns the index of the least significant bit that is set. Only required when B - is an integer type. + is an integer type. The default version of this function is synthesised + from other operations above. +

+ + +

+  

@@ -2201,7 +2606,13 @@ Returns true if cb has bit ui set. Only required when B - is an integer type. + is an integer type. The default version of this function is synthesised + from other operations above. +

+ + +

+  

@@ -2222,7 +2633,13 @@ Sets the bit at index ui in b. Only required when B is an integer - type. + type. The default version of this function is synthesised from + other operations above. +

+ + +

+  

@@ -2242,7 +2659,13 @@ Unsets the bit at index ui in b. Only required when B is an integer - type. + type. The default version of this function is synthesised from + other operations above. +

+ + +

+  

@@ -2263,7 +2686,13 @@ Flips the bit at index ui in b. Only required when B is an integer - type. + type. The default version of this function is synthesised from + other operations above. +

+ + +

+  

@@ -2286,7 +2715,13 @@ common divisor of cb and cb2. Only required when B is an integer - type. + type. The default version of this function is synthesised from + other operations above. +

+ + +

+  

@@ -2309,7 +2744,836 @@ common multiple of cb and cb2. Only required when B is an integer - type. + type. The default version of this function is synthesised from + other operations above. +

+ + +

+   +

+ + + + +

+ eval_gcd(b, + cb, + a) +

+ + +

+ void +

+ + +

+ Sets b to the greatest + common divisor of cb + and cb2. Only required + when B is an integer + type. The type of a + shall be listed in one of the type lists B::signed_types, + B::unsigned_types or B::float_types. The default version + of this function calls eval_gcd(b, cb, B(a)). +

+ + +

+   +

+ + + + +

+ eval_lcm(b, + cb, + a) +

+ + +

+ void +

+ + +

+ Sets b to the least + common multiple of cb + and cb2. Only required + when B is an integer + type. The type of a + shall be listed in one of the type lists B::signed_types, + B::unsigned_types or B::float_types. The default version + of this function calls eval_lcm(b, cb, B(a)). +

+ + +

+   +

+ + + + +

+ eval_gcd(b, + a, + cb) +

+ + +

+ void +

+ + +

+ Sets b to the greatest + common divisor of cb + and a. Only required + when B is an integer + type. The type of a + shall be listed in one of the type lists B::signed_types, + B::unsigned_types or B::float_types. The default version + of this function calls eval_gcd(b, cb, a). +

+ + +

+   +

+ + + + +

+ eval_lcm(b, + a, + cb) +

+ + +

+ void +

+ + +

+ Sets b to the least + common multiple of cb + and a. Only required + when B is an integer + type. The type of a + shall be listed in one of the type lists B::signed_types, + B::unsigned_types or B::float_types. The default version + of this function calls eval_lcm(b, cb, a). +

+ + +

+   +

+ + + + +

+ eval_powm(b, + cb, + cb2, + cb3) +

+ + +

+ void +

+ + +

+ Sets b to the result + of (cb^cb2)%cb3. The default version of this + function is synthesised from other operations above. +

+ + +

+   +

+ + + + +

+ eval_powm(b, + cb, + cb2, + a) +

+ + +

+ void +

+ + +

+ Sets b to the result + of (cb^cb2)%a. The type of a + shall be listed in one of the type lists B::signed_types, + B::unsigned_types. The default version + of this function is synthesised from other operations above. +

+ + +

+   +

+ + + + +

+ eval_powm(b, + cb, + a, + cb2) +

+ + +

+ void +

+ + +

+ Sets b to the result + of (cb^a)%cb2. The type of a + shall be listed in one of the type lists B::signed_types, + B::unsigned_types. The default version + of this function is synthesised from other operations above. +

+ + +

+   +

+ + + + +

+ eval_powm(b, + cb, + a, + a) +

+ + +

+ void +

+ + +

+ Sets b to the result + of (cb^a)%a. The type of a + shall be listed in one of the type lists B::signed_types, + B::unsigned_types. The default version + of this function is synthesised from other operations above. +

+ + +

+   +

+ + + + +

+ Sign manipulation: +

+ +  +  +  + + + +

+ eval_abs(b, + cb) +

+ + +

+ void +

+ + +

+ Set b to the absolute + value of cb. The + default version of this functions assigns cb + to b, and then + calls b.negate() + if eval_get_sign(cb) < + 0. +

+ + +

+   +

+ + + + +

+ eval_fabs(b, + cb) +

+ + +

+ void +

+ + +

+ Set b to the absolute + value of cb. The + default version of this functions assigns cb + to b, and then + calls b.negate() + if eval_get_sign(cb) < + 0. +

+ + +

+   +

+ + + + +

+ Floating point functions: +

+ +  +  +  + + + +

+ eval_fpclassify(cb) +

+ + +

+ int +

+ + +

+ Returns one of the same values returned by std::fpclassify. + Only required when B + is an floating-point type. The default version of this function + will only test for zero cb. +

+ + +

+   +

+ + + + +

+ eval_trunc(b, + cb) +

+ + +

+ void +

+ + +

+ Performs the equivalent operation to std::trunc + on argument cb + and stores the result in b. + Only required when B + is an floating-point type. The default version of this function + is synthesised from other operations above. +

+ + +

+   +

+ + + + +

+ eval_round(b, + cb) +

+ + +

+ void +

+ + +

+ Performs the equivalent operation to std::round + on argument cb + and stores the result in b. + Only required when B + is an floating-point type. The default version of this function + is synthesised from other operations above. +

+ + +

+   +

+ + + + +

+ eval_exp(b, + cb) +

+ + +

+ void +

+ + +

+ Performs the equivalent operation to std::exp + on argument cb + and stores the result in b. + Only required when B + is an floating-point type. The default version of this function + is synthesised from other operations above. +

+ + +

+   +

+ + + + +

+ eval_log(b, + cb) +

+ + +

+ void +

+ + +

+ Performs the equivalent operation to std::log + on argument cb + and stores the result in b. + Only required when B + is an floating-point type. The default version of this function + is synthesised from other operations above. +

+ + +

+   +

+ + + + +

+ eval_log10(b, + cb) +

+ + +

+ void +

+ + +

+ Performs the equivalent operation to std::log10 + on argument cb + and stores the result in b. + Only required when B + is an floating-point type. The default version of this function + is synthesised from other operations above. +

+ + +

+   +

+ + + + +

+ eval_sin(b, + cb) +

+ + +

+ void +

+ + +

+ Performs the equivalent operation to std::sin + on argument cb + and stores the result in b. + Only required when B + is an floating-point type. The default version of this function + is synthesised from other operations above. +

+ + +

+   +

+ + + + +

+ eval_cos(b, + cb) +

+ + +

+ void +

+ + +

+ Performs the equivalent operation to std::cos + on argument cb + and stores the result in b. + Only required when B + is an floating-point type. The default version of this function + is synthesised from other operations above. +

+ + +

+   +

+ + + + +

+ eval_tan(b, + cb) +

+ + +

+ void +

+ + +

+ Performs the equivalent operation to std::exp + on argument cb + and stores the result in b. + Only required when B + is an floating-point type. The default version of this function + is synthesised from other operations above. +

+ + +

+   +

+ + + + +

+ eval_asin(b, + cb) +

+ + +

+ void +

+ + +

+ Performs the equivalent operation to std::asin + on argument cb + and stores the result in b. + Only required when B + is an floating-point type. The default version of this function + is synthesised from other operations above. +

+ + +

+   +

+ + + + +

+ eval_acos(b, + cb) +

+ + +

+ void +

+ + +

+ Performs the equivalent operation to std::acos + on argument cb + and stores the result in b. + Only required when B + is an floating-point type. The default version of this function + is synthesised from other operations above. +

+ + +

+   +

+ + + + +

+ eval_atan(b, + cb) +

+ + +

+ void +

+ + +

+ Performs the equivalent operation to std::atan + on argument cb + and stores the result in b. + Only required when B + is an floating-point type. The default version of this function + is synthesised from other operations above. +

+ + +

+   +

+ + + + +

+ eval_sinh(b, + cb) +

+ + +

+ void +

+ + +

+ Performs the equivalent operation to std::sinh + on argument cb + and stores the result in b. + Only required when B + is an floating-point type. The default version of this function + is synthesised from other operations above. +

+ + +

+   +

+ + + + +

+ eval_cosh(b, + cb) +

+ + +

+ void +

+ + +

+ Performs the equivalent operation to std::cosh + on argument cb + and stores the result in b. + Only required when B + is an floating-point type. The default version of this function + is synthesised from other operations above. +

+ + +

+   +

+ + + + +

+ eval_tanh(b, + cb) +

+ + +

+ void +

+ + +

+ Performs the equivalent operation to std::tanh + on argument cb + and stores the result in b. + Only required when B + is an floating-point type. The default version of this function + is synthesised from other operations above. +

+ + +

+   +

+ + + + +

+ eval_fmod(b, + cb, + cb2) +

+ + +

+ void +

+ + +

+ Performs the equivalent operation to std::fmod + on arguments cb + and cb2, and store + the result in b. + Only required when B + is an floating-point type. The default version of this function + is synthesised from other operations above. +

+ + +

+   +

+ + + + +

+ eval_pow(b, + cb, + cb2) +

+ + +

+ void +

+ + +

+ Performs the equivalent operation to std::pow + on arguments cb + and cb2, and store + the result in b. + Only required when B + is an floating-point type. The default version of this function + is synthesised from other operations above. +

+ + +

+   +

+ + + + +

+ eval_atan2(b, + cb, + cb2) +

+ + +

+ void +

+ + +

+ Performs the equivalent operation to std::atan + on arguments cb + and cb2, and store + the result in b. + Only required when B + is an floating-point type. The default version of this function + is synthesised from other operations above. +

+ + +

+  

@@ -2317,8 +3581,8 @@

- The tables above place no throws requirements on any - of the operations. It is up to each type modelling this concept to decide + When the tables above place no throws requirements on + an operation, then it is up to each type modelling this concept to decide when or whether throwing an exception is desirable. However, thrown exceptions should always either be the type, or inherit from the type std::runtime_error. For example, a floating point type might choose to throw std::overflow_error diff --git a/doc/html/index.html b/doc/html/index.html index ba6104dd..bb9676a2 100644 --- a/doc/html/index.html +++ b/doc/html/index.html @@ -118,7 +118,7 @@ - +

Last revised: August 08, 2012 at 18:23:03 GMT

Last revised: August 09, 2012 at 17:32:59 GMT


diff --git a/doc/multiprecision.qbk b/doc/multiprecision.qbk index ca42b29c..c05e6e9a 100644 --- a/doc/multiprecision.qbk +++ b/doc/multiprecision.qbk @@ -47,7 +47,6 @@ '''] - [section:intro Introduction] The Multiprecision Library provides ['User-defined] integer, rational and floating-point C++ types which @@ -138,6 +137,12 @@ However, there are still many simple expressions such as: Which don't noticably benefit from move support. Therefore, optimal performance comes from having both move-support, and expression templates enabled. +Note that while "moved-from" objects are left in a sane state, they have an unspecified value, and the only permitted +operations on them are destruction or the assignment of a new value. Any other operation should be considered +a programming error and many backends will trigger an assertion if any other operation is attempted. This behavior +allows for optimal performance on move-construction (i.e. no allocation required, we just take ownership of the existing +object's internal state), while maintaining usability in the standard library containers. + [h4 Expression Templates] TODO: compare to rvalue refs. @@ -1730,13 +1735,17 @@ More information on this type can be found in the [link boost_multiprecision.tut [section:backendconc Backend Requirements] The requirements on the `Backend` template argument to `number` are split up into -compulsory requirements, and optional requirements that are either to improve performance -or provide optional features. +sections: compulsary and optional. -TODO: Add optional construction support, add throws specification, clarify what compulsory means. +Compulsary requirements have no default implementation in the library, therefore if the feature +they implement is to be supported at all, then they must be implemented by the backend. + +Optional requirements have default implementations that are called if the backend doesn't provide +it's own. Typically the backend will implement these to improve performance. In the following tables, type B is the `Backend` template arument to `number`, `b` and `b2` are -a variables of type B, `cb` and `cb2` are constant variables of type B, `a` is a variable of Arithmetic type, +a variables of type B, `cb`, `cb2` and `cb3` are constant variables of type `const B`, +`rb` is a variable of type `B&&`, `a` and `a2` are variables of Arithmetic type, `s` is a variable of type `const char*`, `ui` is a variable of type `unsigned`, `bb` is a variable of type `bool`, `pa` is a variable of type pointer-to-arithmetic-type, `exp` is a variable of type `B::exp_type`, `pexp` is a variable of type `B::exp_type*`, `i` is a variable of type `int`, `pi` pointer to a variable of type `int`, @@ -1744,157 +1753,325 @@ B2 is another type that meets these requirements, b2 is a variable of type B2. [table Compulsory Requirements on the Backend type. -[[Expression][Return Type][Comments]] +[[Expression][Return Type][Comments][Throws]] [[`B::signed_types`][`mpl::list`][A list of signed integral types that can be assigned to type B. The types shall be - listed in order of size, smallest first, and shall terminate in the type that is `std::intmax_t`.]] + listed in order of size, smallest first, and shall terminate in the type that is `std::intmax_t`.][[space]]] [[`B::unsigned_types`][`mpl::list`][A list of unsigned integral types that can be assigned to type B. The types shall be - listed in order of size, smallest first, and shall terminate in the type that is `std::uintmax_t`.]] + listed in order of size, smallest first, and shall terminate in the type that is `std::uintmax_t`.][[space]]] [[`B::float_types`][`mpl::list`][A list of floating-point types that can be assigned to type B.The types shall be - listed in order of size, smallest first, and shall terminate in type `long double`.]] -[[`B::exponent_type`][A signed integral type.][The type of the exponent of type B.]] -[[`B()`][ ][Default constructor.]] -[[`B(cb)`][ ][Copy Constructor.]] -[[`b = b`][`B&`][Assignment operator.]] + listed in order of size, smallest first, and shall terminate in type `long double`.][[space]]] +[[`B::exponent_type`][A signed integral type.][The type of the exponent of type B. This type is required only for floating point types.][[space]]] +[[`B()`][ ][Default constructor.][[space]]] +[[`B(cb)`][ ][Copy Constructor.][[space]]] +[[`b = b`][`B&`][Assignment operator.][[space]]] [[`b = a`][`B&`][Assignment from an Arithmetic type. The type of `a` shall be listed in one of the type lists - `B::signed_types`, `B::unsigned_types` or `B::float_types`.]] -[[`b = s`][`B&`][Assignment from a string.]] -[[`b.swap(b)`][`void`][Swaps the contents of its arguments.]] + `B::signed_types`, `B::unsigned_types` or `B::float_types`.][[space]]] +[[`b = s`][`B&`][Assignment from a string.][Throws a `std::runtime_error` if the string could not be interpretted as a valid number.]] +[[`b.swap(b)`][`void`][Swaps the contents of its arguments.][`noexcept`]] [[`cb.str(ui, bb)`][`std::string`][Returns the string representation of `b` with `ui` digits and in scientific format if `bb` is `true`. - If `ui` is zero, then returns as many digits as are required to reconstruct the original value.]] -[[`b.negate()`][`void`][Negates `b`.]] + If `ui` is zero, then returns as many digits as are required to reconstruct the original value.][[space]]] +[[`b.negate()`][`void`][Negates `b`.][[space]]] [[`cb.compare(cb2)`][`int`][Compares `cb` and `cb2`, returns a value less than zero if `cb < cb2`, a value greater than zero if `cb > cb2` and zero - if `cb == cb2`.]] + if `cb == cb2`.][`noexcept`]] [[`cb.compare(a)`][`int`][Compares `cb` and `a`, returns a value less than zero if `cb < a`, a value greater than zero if `cb > a` and zero if `cb == a`. The type of `a` shall be listed in one of the type lists - `B::signed_types`, `B::unsigned_types` or `B::float_types`.]] -[[`eval_add(b, cb)`][`void`][Adds `cb` to `b`.]] -[[`eval_subtract(b, cb)`][`void`][Subtracts `cb` from `b`.]] -[[`eval_multiply(b, cb)`][`void`][Multiplies `b` by `cb`.]] -[[`eval_divide(b, cb)`][`void`][Divides `b` by `cb`.]] -[[`eval_modulus(b, cb)`][`void`][Computes `b %= cb`, only required when `B` is an integer type.]] -[[`eval_bitwise_and(b, cb)`][`void`][Computes `b &= cb`, only required when `B` is an integer type.]] -[[`eval_bitwise_or(b, cb)`][`void`][Computes `b |= cb`, only required when `B` is an integer type.]] -[[`eval_bitwise_xor(b, cb)`][`void`][Computes `b ^= cb`, only required when `B` is an integer type.]] -[[`eval_complement(b, cb)`][`void`][Computes the ones-complement of `cb` and stores the result in `b`, only required when `B` is an integer type.]] -[[`eval_left_shift(b, ui)`][`void`][Computes `b <<= ui`, only required when `B` is an integer type.]] -[[`eval_right_shift(b, ui)`][`void`][Computes `b >>= ui`, only required when `B` is an integer type.]] + `B::signed_types`, `B::unsigned_types` or `B::float_types`.][[space]]] +[[`eval_add(b, cb)`][`void`][Adds `cb` to `b`.][[space]]] +[[`eval_subtract(b, cb)`][`void`][Subtracts `cb` from `b`.][[space]]] +[[`eval_multiply(b, cb)`][`void`][Multiplies `b` by `cb`.][[space]]] +[[`eval_divide(b, cb)`][`void`][Divides `b` by `cb`.] + [`std::overflow_error` if cb has the value zero, and `std::numeric_limits >::has_infinity == false`]] +[[`eval_modulus(b, cb)`][`void`][Computes `b %= cb`, only required when `B` is an integer type.] + [`std::overflow_error` if cb has the value zero.]] +[[`eval_bitwise_and(b, cb)`][`void`][Computes `b &= cb`, only required when `B` is an integer type.][[space]]] +[[`eval_bitwise_or(b, cb)`][`void`][Computes `b |= cb`, only required when `B` is an integer type.][[space]]] +[[`eval_bitwise_xor(b, cb)`][`void`][Computes `b ^= cb`, only required when `B` is an integer type.][[space]]] +[[`eval_complement(b, cb)`][`void`][Computes the ones-complement of `cb` and stores the result in `b`, only required when `B` is an integer type.][[space]]] +[[`eval_left_shift(b, ui)`][`void`][Computes `b <<= ui`, only required when `B` is an integer type.][[space]]] +[[`eval_right_shift(b, ui)`][`void`][Computes `b >>= ui`, only required when `B` is an integer type.][[space]]] [[`eval_convert_to(pa, cb)`][`void`][Converts `cb` to the type of `*pa` and store the result in `*pa`. Type `B` shall support conversion to at least types `std::intmax_t`, `std::uintmax_t` and `long long`. Conversion to other arithmetic types can then be synthesised using other operations. - Conversions to other types are entirely optional.]] -[[`eval_frexp(b, cb, pexp)`][`void`][Stores values in `b` and `*pexp` such that the value of `cb` is b * 2[super *pexp], only required when `B` is a floating-point type.]] -[[`eval_ldexp(b, cb, exp)`][`void`][Stores a value in `b` that is cb * 2[super exp], only required when `B` is a floating-point type.]] -[[`eval_frexp(b, cb, pi)`][`void`][Stores values in `b` and `*pi` such that the value of `cb` is b * 2[super *pi], only required when `B` is a floating-point type.]] -[[`eval_ldexp(b, cb, i)`][`void`][Stores a value in `b` that is cb * 2[super i], only required when `B` is a floating-point type.]] -[[`eval_floor(b, cb)`][`void`][Stores the floor of `cb` in `b`, only required when `B` is a floating-point type.]] -[[`eval_ceil(b, cb)`][`void`][Stores the ceiling of `cb` in `b`, only required when `B` is a floating-point type.]] -[[`eval_sqrt(b, cb)`][`void`][Stores the square root of `cb` in `b`, only required when `B` is a floating-point type.]] + Conversions to other types are entirely optional.][[space]]] +[[`eval_frexp(b, cb, pexp)`][`void`][Stores values in `b` and `*pexp` such that the value of `cb` is b * 2[super *pexp], only required when `B` is a floating-point type.][[space]]] +[[`eval_ldexp(b, cb, exp)`][`void`][Stores a value in `b` that is cb * 2[super exp], only required when `B` is a floating-point type.][[space]]] +[[`eval_frexp(b, cb, pi)`][`void`][Stores values in `b` and `*pi` such that the value of `cb` is b * 2[super *pi], only required when `B` is a floating-point type.] + [`std::runtime_error` if the exponent of cb is too large to be stored in an `int`.]] +[[`eval_ldexp(b, cb, i)`][`void`][Stores a value in `b` that is cb * 2[super i], only required when `B` is a floating-point type.][[space]]] +[[`eval_floor(b, cb)`][`void`][Stores the floor of `cb` in `b`, only required when `B` is a floating-point type.][[space]]] +[[`eval_ceil(b, cb)`][`void`][Stores the ceiling of `cb` in `b`, only required when `B` is a floating-point type.][[space]]] +[[`eval_sqrt(b, cb)`][`void`][Stores the square root of `cb` in `b`, only required when `B` is a floating-point type.][[space]]] [[`boost::multiprecision::number_category::type`][`mpl::int_`][`N` is one of the values `number_kind_integer`, `number_kind_floating_point`, `number_kind_rational` or `number_kind_fixed_point`. - Defaults to `number_kind_floating_point`.]] + Defaults to `number_kind_floating_point`.][[space]]] ] [table Optional Requirements on the Backend Type -[[Expression][Returns][Comments]] -[[`B(b2)`][`B`][Copy constructor from a different back-end type.]] -[[`b = b2`][`b&`][Assignment operator from a different back-end type.]] +[[Expression][Returns][Comments][Throws]] + +[[['Construct and assign:]]] +[[`B(rb)`][`B`][Move constructor. Afterwards variable `rb` shall be in sane state, albeit with unspecified value. + Only destruction and assignment to the moved-from variable `rb` need be supported after the operation.][`noexcept`]] +[[`b = rb`][`B&`][Move-assign. Afterwards variable `rb` shall be in sane state, albeit with unspecified value. + Only destruction and assignment to the moved-from variable `rb` need be supported after the operation.][`noexcept`]] +[[`B(a)`][`B`][Direct construction from an arithmetic type. The type of `a` shall be listed in one of the type lists + `B::signed_types`, `B::unsigned_types` or `B::float_types`. + When not provided, this operation is simulated using default-construction followed by assignment.][[space]]] +[[`B(b2)`][`B`][Copy constructor from a different back-end type. When not provided, a generic interconversion routine is used.][[space]]] +[[`b = b2`][`b&`][Assignment operator from a different back-end type. When not provided, a generic interconversion routine is used.][[space]]] [[`assign_components(b, a, a)`][`void`][Assigns to `b` the two components in the following arguments. - Only applies to rational and complex number types.]] + Only applies to rational and complex number types. + When not provided, arithmetic operations are used to synthesise the result from the two values.][[space]]] [[`assign_components(b, b2, b2)`][`void`][Assigns to `b` the two components in the following arguments. - Only applies to rational and complex number types.]] + Only applies to rational and complex number types. + When not provided, arithmetic operations are used to synthesise the result from the two values.][[space]]] + +[[['Comparisons:]]] +[[`eval_eq(cb, cb2)`][`bool`][Returns `true` if `cb` and `cb2` are equal in value. + When not provided, the default implementation returns `cb.compare(cb2) == 0`.][`noexcept`]] +[[`eval_eq(cb, a)`][`bool`][Returns `true` if `cb` and `a` are equal in value. + The type of `a` shall be listed in one of the type lists + `B::signed_types`, `B::unsigned_types` or `B::float_types`. + When not provided, return the equivalent of `eval_eq(cb, B(a))`.][[space]]] +[[`eval_eq(a, cb)`][`bool`][Returns `true` if `cb` and `a` are equal in value. + The type of `a` shall be listed in one of the type lists + `B::signed_types`, `B::unsigned_types` or `B::float_types`. + When not provided, the default version returns `eval_eq(cb, a)`.][[space]]] +[[`eval_lt(cb, cb2)`][`bool`][Returns `true` if `cb` is less than `cb2` in value. + When not provided, the default implementation returns `cb.compare(cb2) < 0`.][`noexcept`]] +[[`eval_lt(cb, a)`][`bool`][Returns `true` if `cb` is less than `a` in value. + The type of `a` shall be listed in one of the type lists + `B::signed_types`, `B::unsigned_types` or `B::float_types`. + When not provided, the default implementation returns `eval_lt(cb, B(a))`.][[space]]] +[[`eval_lt(a, cb)`][`bool`][Returns `true` if `a` is less than `cb` in value. + The type of `a` shall be listed in one of the type lists + `B::signed_types`, `B::unsigned_types` or `B::float_types`. + When not provided, the default implementation returns `eval_gt(cb, a)`.][[space]]] +[[`eval_gt(cb, cb2)`][`bool`][Returns `true` if `cb` is greater than `cb2` in value. + When not provided, the default implementation returns `cb.compare(cb2) > 0`.][`noexcept`]] +[[`eval_gt(cb, a)`][`bool`][Returns `true` if `cb` is greater than `a` in value. + The type of `a` shall be listed in one of the type lists + `B::signed_types`, `B::unsigned_types` or `B::float_types`. + When not provided, the default implementation returns `eval_gt(cb, B(a))`.][[space]]] +[[`eval_gt(a, cb)`][`bool`][Returns `true` if `a` is greater than `cb` in value. + The type of `a` shall be listed in one of the type lists + `B::signed_types`, `B::unsigned_types` or `B::float_types`. + When not provided, the default implementation returns `eval_lt(cb, a)`.][[space]]] +[[`eval_is_zero(cb)`][`bool`][Returns `true` if `cb` is zero, otherwise `false`. The default version of this function + returns `cb.compare(ui_type(0)) == 0`, where `ui_type` is `ui_type` is + `typename mpl::front::type`.][[space]]] +[[`eval_get_sign(cb)`][`int`][Returns a value < zero if `cb` is negative, a value > zero if `cb` is positive, and zero if `cb` is zero. + The default version of this function + returns `cb.compare(ui_type(0))`, where `ui_type` is `ui_type` is + `typename mpl::front::type`.][[space]]] + +[[['Basic arithmetic:]]] [[`eval_add(b, a)`][`void`][Adds `a` to `b`. The type of `a` shall be listed in one of the type lists - `B::signed_types`, `B::unsigned_types` or `B::float_types`.]] -[[`eval_subtract(b, a)`][`void`][Subtracts `a` from `b`. The type of `a` shall be listed in one of the type lists - `B::signed_types`, `B::unsigned_types` or `B::float_types`.]] -[[`eval_multiply(b, a)`][`void`][Multiplies `b` by `a`. The type of `a` shall be listed in one of the type lists - `B::signed_types`, `B::unsigned_types` or `B::float_types`.]] -[[`eval_divide(b, a)`][`void`][Divides `b` by `a`. The type of `a` shall be listed in one of the type lists - `B::signed_types`, `B::unsigned_types` or `B::float_types`.]] -[[`eval_modulus(b, a)`][`void`][Computes `b %= cb`, only required when `B` is an integer type. The type of `a` shall be listed in one of the type lists - `B::signed_types`, `B::unsigned_types` or `B::float_types`.]] -[[`eval_bitwise_and(b, a)`][`void`][Computes `b &= cb`, only required when `B` is an integer type. The type of `a` shall be listed in one of the type lists - `B::signed_types`, `B::unsigned_types` or `B::float_types`.]] -[[`eval_bitwise_or(b, a)`][`void`][Computes `b |= cb`, only required when `B` is an integer type. The type of `a` shall be listed in one of the type lists - `B::signed_types`, `B::unsigned_types` or `B::float_types`.]] -[[`eval_bitwise_xor(b, a)`][`void`][Computes `b ^= cb`, only required when `B` is an integer type. The type of `a` shall be listed in one of the type lists - `B::signed_types`, `B::unsigned_types` or `B::float_types`.]] -[[`eval_add(b, cb, cb2)`][`void`][Add `cb` to `cb2` and stores the result in `b`.]] -[[`eval_subtract(b, cb, cb2)`][`void`][Subtracts `cb2` from `cb` and stores the result in `b`.]] -[[`eval_multiply(b, cb, cb2)`][`void`][Multiplies `cb` by `cb2` and stores the result in `b`.]] -[[`eval_divide(b, cb, cb2)`][`void`][Divides `cb` by `cb2` and stores the result in `b`.]] + `B::signed_types`, `B::unsigned_types` or `B::float_types`. + When not provided, the default version calls `eval_add(b, B(a))`][[space]]] +[[`eval_add(b, cb, cb2)`][`void`][Add `cb` to `cb2` and stores the result in `b`. + When not provided, does the equivalent of `b = cb; eval_add(b, cb2)`.][[space]]] [[`eval_add(b, cb, a)`][`void`][Add `cb` to `a` and stores the result in `b`. The type of `a` shall be listed in one of the type lists - `B::signed_types`, `B::unsigned_types` or `B::float_types`.]] -[[`eval_subtract(b, cb, a)`][`void`][Subtracts `a` from `cb` and stores the result in `b`. The type of `a` shall be listed in one of the type lists - `B::signed_types`, `B::unsigned_types` or `B::float_types`.]] -[[`eval_multiply(b, cb, a)`][`void`][Multiplies `cb` by `a` and stores the result in `b`. The type of `a` shall be listed in one of the type lists - `B::signed_types`, `B::unsigned_types` or `B::float_types`.]] -[[`eval_divide(b, cb, a)`][`void`][Divides `cb` by `a` and stores the result in `b`. The type of `a` shall be listed in one of the type lists - `B::signed_types`, `B::unsigned_types` or `B::float_types`.]] -[[`eval_modulus(b, cb, cb2)`][`void`][Computes `cb % cb2` and stores the result in `b`, only required when `B` is an integer type.]] -[[`eval_bitwise_and(b, cb, cb2)`][`void`][Computes `cb & cb2` and stores the result in `b`, only required when `B` is an integer type.]] -[[`eval_bitwise_or(b, cb, cb2)`][`void`][Computes `cb | cb2` and stores the result in `b`, only required when `B` is an integer type.]] -[[`eval_bitwise_xor(b, cb, cb2)`][`void`][Computes `cb ^ cb2` and stores the result in `b`, only required when `B` is an integer type.]] + `B::signed_types`, `B::unsigned_types` or `B::float_types`. + When not provided, does the equivalent of `eval_add(b, cb, B(a))`.][[space]]] [[`eval_add(b, a, cb)`][`void`][Add `a` to `cb` and stores the result in `b`. The type of `a` shall be listed in one of the type lists - `B::signed_types`, `B::unsigned_types` or `B::float_types`.]] + `B::signed_types`, `B::unsigned_types` or `B::float_types`. + When not provided, does the equivalent of `eval_add(b, cb, a)`.][[space]]] +[[`eval_subtract(b, a)`][`void`][Subtracts `a` from `b`. The type of `a` shall be listed in one of the type lists + `B::signed_types`, `B::unsigned_types` or `B::float_types`. + When not provided, the default version calls `eval_subtract(b, B(a))`][[space]]] +[[`eval_subtract(b, cb, cb2)`][`void`][Subtracts `cb2` from `cb` and stores the result in `b`. + When not provided, does the equivalent of `b = cb; eval_subtract(b, cb2)`.][[space]]] +[[`eval_subtract(b, cb, a)`][`void`][Subtracts `a` from `cb` and stores the result in `b`. The type of `a` shall be listed in one of the type lists + `B::signed_types`, `B::unsigned_types` or `B::float_types`. + When not provided, does the equivalent of `eval_subtract(b, cb, B(a))`.][[space]]] [[`eval_subtract(b, a, cb)`][`void`][Subtracts `cb` from `a` and stores the result in `b`. The type of `a` shall be listed in one of the type lists - `B::signed_types`, `B::unsigned_types` or `B::float_types`.]] + `B::signed_types`, `B::unsigned_types` or `B::float_types`. + When not provided, does the equivalent of `eval_subtract(b, cb, a); b.negate();`.][[space]]] +[[`eval_multiply(b, a)`][`void`][Multiplies `b` by `a`. The type of `a` shall be listed in one of the type lists + `B::signed_types`, `B::unsigned_types` or `B::float_types`. + When not provided, the default version calls `eval_multiply(b, B(a))`][[space]]] +[[`eval_multiply(b, cb, cb2)`][`void`][Multiplies `cb` by `cb2` and stores the result in `b`. + When not provided, does the equivalent of `b = cb; eval_multiply(b, cb2)`.][[space]]] +[[`eval_multiply(b, cb, a)`][`void`][Multiplies `cb` by `a` and stores the result in `b`. The type of `a` shall be listed in one of the type lists + `B::signed_types`, `B::unsigned_types` or `B::float_types`. + When not provided, does the equivalent of `eval_multiply(b, cb, B(a))`.][[space]]] [[`eval_multiply(b, a, cb)`][`void`][Multiplies `a` by `cb` and stores the result in `b`. The type of `a` shall be listed in one of the type lists - `B::signed_types`, `B::unsigned_types` or `B::float_types`.]] + `B::signed_types`, `B::unsigned_types` or `B::float_types`. + When not provided, does the equivalent of `eval_multiply(b, cb, a)`.][[space]]] +[[`eval_divide(b, a)`][`void`][Divides `b` by `a`. The type of `a` shall be listed in one of the type lists + `B::signed_types`, `B::unsigned_types` or `B::float_types`. + When not provided, the default version calls `eval_divide(b, B(a))`] + [`std::overflow_error` if `a` has the value zero, and `std::numeric_limits >::has_infinity == false`]] +[[`eval_divide(b, cb, cb2)`][`void`][Divides `cb` by `cb2` and stores the result in `b`. + When not provided, does the equivalent of `b = cb; eval_divide(b, cb2)`.] + [`std::overflow_error` if `cb2` has the value zero, and `std::numeric_limits >::has_infinity == false`]] +[[`eval_divide(b, cb, a)`][`void`][Divides `cb` by `a` and stores the result in `b`. The type of `a` shall be listed in one of the type lists + `B::signed_types`, `B::unsigned_types` or `B::float_types`. + When not provided, does the equivalent of `eval_divide(b, cb, B(a))`.] + [`std::overflow_error` if `a` has the value zero, and `std::numeric_limits >::has_infinity == false`]] [[`eval_divide(b, a, cb)`][`void`][Divides `a` by `cb` and stores the result in `b`. The type of `a` shall be listed in one of the type lists - `B::signed_types`, `B::unsigned_types` or `B::float_types`.]] + `B::signed_types`, `B::unsigned_types` or `B::float_types`. + When not provided, does the equivalent of `eval_divide(b, B(a), cb)`.] + [`std::overflow_error` if cb has the value zero, and `std::numeric_limits >::has_infinity == false`]] +[[`eval_increment(b)`][void][Increments the value of `b` by one. + When not provided, does the equivalent of `eval_add(b, static_cast(1u))`. + Where `ui_type` is `typename mpl::front::type`.][[space]]] +[[`eval_decrement(b)`][void][Decrements the value of `b` by one. + When not provided, does the equivalent of `eval_subtract(b, static_cast(1u))`. + Where `ui_type` is `typename mpl::front::type`.][[space]]] + +[[['Integer specific operations:]]] +[[`eval_modulus(b, a)`][`void`][Computes `b %= cb`, only required when `B` is an integer type. The type of `a` shall be listed in one of the type lists + `B::signed_types`, `B::unsigned_types` or `B::float_types`. + When not provided, the default version calls `eval_modulus(b, B(a))`] + [`std::overflow_error` if `a` has the value zero.]] +[[`eval_modulus(b, cb, cb2)`][`void`][Computes `cb % cb2` and stores the result in `b`, only required when `B` is an integer type. + When not provided, does the equivalent of `b = cb; eval_modulus(b, cb2)`.] + [`std::overflow_error` if `a` has the value zero.]] [[`eval_modulus(b, cb, a)`][`void`][Computes `cb % a` and stores the result in `b`, only required when `B` is an integer type. The type of `a` shall be listed in one of the type lists - `B::signed_types`, `B::unsigned_types` or `B::float_types`.]] -[[`eval_bitwise_and(b, cb, a)`][`void`][Computes `cb & a` and stores the result in `b`, only required when `B` is an integer type. The type of `a` shall be listed in one of the type lists - `B::signed_types`, `B::unsigned_types` or `B::float_types`.]] -[[`eval_bitwise_or(b, cb, a)`][`void`][Computes `cb | a` and stores the result in `b`, only required when `B` is an integer type. The type of `a` shall be listed in one of the type lists - `B::signed_types`, `B::unsigned_types` or `B::float_types`.]] -[[`eval_bitwise_xor(b, cb, a)`][`void`][Computes `cb ^ a` and stores the result in `b`, only required when `B` is an integer type. The type of `a` shall be listed in one of the type lists - `B::signed_types`, `B::unsigned_types` or `B::float_types`.]] + `B::signed_types`, `B::unsigned_types` or `B::float_types`. + When not provided, does the equivalent of `eval_modulus(b, cb, B(a))`.] + [`std::overflow_error` if `a` has the value zero.]] [[`eval_modulus(b, a, cb)`][`void`][Computes `cb % a` and stores the result in `b`, only required when `B` is an integer type. The type of `a` shall be listed in one of the type lists - `B::signed_types`, `B::unsigned_types` or `B::float_types`.]] + `B::signed_types`, `B::unsigned_types` or `B::float_types`. + When not provided, does the equivalent of `eval_modulus(b, B(a), cb)`.] + [`std::overflow_error` if `a` has the value zero.]] +[[`eval_bitwise_and(b, a)`][`void`][Computes `b &= cb`, only required when `B` is an integer type. The type of `a` shall be listed in one of the type lists + `B::signed_types`, `B::unsigned_types` or `B::float_types`. + When not provided, the default version calls `eval_bitwise_and(b, B(a))`][[space]]] +[[`eval_bitwise_and(b, cb, cb2)`][`void`][Computes `cb & cb2` and stores the result in `b`, only required when `B` is an integer type. + When not provided, does the equivalent of `b = cb; eval_bitwise_and(b, cb2)`.][[space]]] +[[`eval_bitwise_and(b, cb, a)`][`void`][Computes `cb & a` and stores the result in `b`, only required when `B` is an integer type. The type of `a` shall be listed in one of the type lists + `B::signed_types`, `B::unsigned_types` or `B::float_types`. + When not provided, does the equivalent of `eval_bitwise_and(b, cb, B(a))`.][[space]]] [[`eval_bitwise_and(b, a, cb)`][`void`][Computes `cb & a` and stores the result in `b`, only required when `B` is an integer type. The type of `a` shall be listed in one of the type lists - `B::signed_types`, `B::unsigned_types` or `B::float_types`.]] + `B::signed_types`, `B::unsigned_types` or `B::float_types`. + When not provided, does the equivalent of `eval_bitwise_and(b, cb, a)`.][[space]]] +[[`eval_bitwise_or(b, a)`][`void`][Computes `b |= cb`, only required when `B` is an integer type. The type of `a` shall be listed in one of the type lists + `B::signed_types`, `B::unsigned_types` or `B::float_types`. + When not provided, the default version calls `eval_bitwise_or(b, B(a))`][[space]]] +[[`eval_bitwise_or(b, cb, cb2)`][`void`][Computes `cb | cb2` and stores the result in `b`, only required when `B` is an integer type. + When not provided, does the equivalent of `b = cb; eval_bitwise_or(b, cb2)`.][[space]]] +[[`eval_bitwise_or(b, cb, a)`][`void`][Computes `cb | a` and stores the result in `b`, only required when `B` is an integer type. The type of `a` shall be listed in one of the type lists + `B::signed_types`, `B::unsigned_types` or `B::float_types`. + When not provided, does the equivalent of `eval_bitwise_or(b, cb, B(a))`.][[space]]] [[`eval_bitwise_or(b, a, cb)`][`void`][Computes `cb | a` and stores the result in `b`, only required when `B` is an integer type. The type of `a` shall be listed in one of the type lists - `B::signed_types`, `B::unsigned_types` or `B::float_types`.]] + `B::signed_types`, `B::unsigned_types` or `B::float_types`. + When not provided, does the equivalent of `eval_bitwise_or(b, cb, a)`.][[space]]] +[[`eval_bitwise_xor(b, a)`][`void`][Computes `b ^= cb`, only required when `B` is an integer type. The type of `a` shall be listed in one of the type lists + `B::signed_types`, `B::unsigned_types` or `B::float_types`. + When not provided, the default version calls `eval_bitwise_xor(b, B(a))`][[space]]] +[[`eval_bitwise_xor(b, cb, cb2)`][`void`][Computes `cb ^ cb2` and stores the result in `b`, only required when `B` is an integer type. + When not provided, does the equivalent of `b = cb; eval_bitwise_xor(b, cb2)`.][[space]]] +[[`eval_bitwise_xor(b, cb, a)`][`void`][Computes `cb ^ a` and stores the result in `b`, only required when `B` is an integer type. The type of `a` shall be listed in one of the type lists + `B::signed_types`, `B::unsigned_types` or `B::float_types`. + When not provided, does the equivalent of `eval_bitwise_xor(b, cb, B(a))`.][[space]]] [[`eval_bitwise_xor(b, a, cb)`][`void`][Computes `a ^ cb` and stores the result in `b`, only required when `B` is an integer type. The type of `a` shall be listed in one of the type lists - `B::signed_types`, `B::unsigned_types` or `B::float_types`.]] -[[`eval_left_shift(b, cb, ui)`][`void`][Computes `cb << ui` and stores the result in `b`, only required when `B` is an integer type.]] -[[`eval_right_shift(b, cb, ui)`][`void`][Computes `cb >> ui` and stores the result in `b`, only required when `B` is an integer type.]] -[[`eval_increment(b)`][void][Increments the value of `b` by one.]] -[[`eval_decrement(b)`][void][Decrements the value of `b` by one.]] -[[`eval_is_zero(cb)`][`bool`][Returns `true` if `cb` is zero, otherwise `false`]] -[[`eval_get_sign(cb)`][`int`][Returns a value < zero if `cb` is negative, a value > zero if `cb` is positive, and zero if `cb` is zero.]] -[[`eval_abs(b, cb)`][`void`][Set `b` to the absolute value of `cb`.]] -[[`eval_fabs(b, cb)`][`void`][Set `b` to the absolute value of `cb`.]] -[[`eval_fpclassify(cb)`][`int`][Returns one of the same values returned by `std::fpclassify`. Only required when `B` is an floating-point type.]] -[[`eval_trunc(b, cb)`][`void`][Performs the equivalent operation to `std::trunc` on argument `cb` and stores the result in `b`. Only required when `B` is an floating-point type.]] -[[`eval_round(b, cb)`][`void`][Performs the equivalent operation to `std::round` on argument `cb` and stores the result in `b`. Only required when `B` is an floating-point type.]] -[[`eval_exp(b, cb)`][`void`][Performs the equivalent operation to `std::exp` on argument `cb` and stores the result in `b`. Only required when `B` is an floating-point type.]] -[[`eval_log(b, cb)`][`void`][Performs the equivalent operation to `std::log` on argument `cb` and stores the result in `b`. Only required when `B` is an floating-point type.]] -[[`eval_log10(b, cb)`][`void`][Performs the equivalent operation to `std::log10` on argument `cb` and stores the result in `b`. Only required when `B` is an floating-point type.]] -[[`eval_sin(b, cb)`][`void`][Performs the equivalent operation to `std::sin` on argument `cb` and stores the result in `b`. Only required when `B` is an floating-point type.]] -[[`eval_cos(b, cb)`][`void`][Performs the equivalent operation to `std::cos` on argument `cb` and stores the result in `b`. Only required when `B` is an floating-point type.]] -[[`eval_tan(b, cb)`][`void`][Performs the equivalent operation to `std::exp` on argument `cb` and stores the result in `b`. Only required when `B` is an floating-point type.]] -[[`eval_asin(b, cb)`][`void`][Performs the equivalent operation to `std::asin` on argument `cb` and stores the result in `b`. Only required when `B` is an floating-point type.]] -[[`eval_acos(b, cb)`][`void`][Performs the equivalent operation to `std::acos` on argument `cb` and stores the result in `b`. Only required when `B` is an floating-point type.]] -[[`eval_atan(b, cb)`][`void`][Performs the equivalent operation to `std::atan` on argument `cb` and stores the result in `b`. Only required when `B` is an floating-point type.]] -[[`eval_sinh(b, cb)`][`void`][Performs the equivalent operation to `std::sinh` on argument `cb` and stores the result in `b`. Only required when `B` is an floating-point type.]] -[[`eval_cosh(b, cb)`][`void`][Performs the equivalent operation to `std::cosh` on argument `cb` and stores the result in `b`. Only required when `B` is an floating-point type.]] -[[`eval_tanh(b, cb)`][`void`][Performs the equivalent operation to `std::tanh` on argument `cb` and stores the result in `b`. Only required when `B` is an floating-point type.]] -[[`eval_fmod(b, cb, cb2)`][`void`][Performs the equivalent operation to `std::fmod` on arguments `cb` and `cb2`, and store the result in `b`. Only required when `B` is an floating-point type.]] -[[`eval_pow(b, cb, cb2)`][`void`][Performs the equivalent operation to `std::pow` on arguments `cb` and `cb2`, and store the result in `b`. Only required when `B` is an floating-point type.]] -[[`eval_atan2(b, cb, cb2)`][`void`][Performs the equivalent operation to `std::atan` on arguments `cb` and `cb2`, and store the result in `b`. Only required when `B` is an floating-point type.]] -[[`eval_qr(cb, cb2, b, b2)`][`void`][Sets `b` to the result of `cb / cb2` and `b2` to the result of `cb % cb2`. Only required when `B` is an integer type.]] -[[`eval_integer_modulus(cb, ui)`][`unsigned`][Returns the result of `cb % ui`. Only required when `B` is an integer type.]] -[[`eval_lsb(cb)`][`unsigned`][Returns the index of the least significant bit that is set. Only required when `B` is an integer type.]] -[[`eval_bit_test(cb, ui)`][`bool`][Returns true if `cb` has bit `ui` set. Only required when `B` is an integer type.]] -[[`eval_bit_set(b, ui)`][`void`][Sets the bit at index `ui` in `b`. Only required when `B` is an integer type.]] -[[`eval_bit_unset(b, ui)`][`void`][Unsets the bit at index `ui` in `b`. Only required when `B` is an integer type.]] -[[`eval_bit_flip(b, ui)`][`void`][Flips the bit at index `ui` in `b`. Only required when `B` is an integer type.]] -[[`eval_gcd(b, cb, cb2)`][`void`][Sets `b` to the greatest common divisor of `cb` and `cb2`. Only required when `B` is an integer type.]] -[[`eval_lcm(b, cb, cb2)`][`void`][Sets `b` to the least common multiple of `cb` and `cb2`. Only required when `B` is an integer type.]] + `B::signed_types`, `B::unsigned_types` or `B::float_types`. + When not provided, does the equivalent of `eval_bitwise_xor(b, cb, a)`.][[space]]] +[[`eval_left_shift(b, cb, ui)`][`void`][Computes `cb << ui` and stores the result in `b`, only required when `B` is an integer type. + When not provided, does the equivalent of `b = cb; eval_left_shift(b, a);`.][[space]]] +[[`eval_right_shift(b, cb, ui)`][`void`][Computes `cb >> ui` and stores the result in `b`, only required when `B` is an integer type. + When not provided, does the equivalent of `b = cb; eval_right_shift(b, a);`.][[space]]] +[[`eval_qr(cb, cb2, b, b2)`][`void`][Sets `b` to the result of `cb / cb2` and `b2` to the result of `cb % cb2`. Only required when `B` is an integer type. + The default version of this function is synthesised from other operations above.] + [`std::overflow_error` if `a` has the value zero.]] +[[`eval_integer_modulus(cb, ui)`][`unsigned`][Returns the result of `cb % ui`. Only required when `B` is an integer type. + The default version of this function is synthesised from other operations above.] + [`std::overflow_error` if `a` has the value zero.]] +[[`eval_lsb(cb)`][`unsigned`][Returns the index of the least significant bit that is set. Only required when `B` is an integer type. + The default version of this function is synthesised from other operations above.][[space]]] +[[`eval_bit_test(cb, ui)`][`bool`][Returns true if `cb` has bit `ui` set. Only required when `B` is an integer type. + The default version of this function is synthesised from other operations above.][[space]]] +[[`eval_bit_set(b, ui)`][`void`][Sets the bit at index `ui` in `b`. Only required when `B` is an integer type. + The default version of this function is synthesised from other operations above.][[space]]] +[[`eval_bit_unset(b, ui)`][`void`][Unsets the bit at index `ui` in `b`. Only required when `B` is an integer type. + The default version of this function is synthesised from other operations above.][[space]]] +[[`eval_bit_flip(b, ui)`][`void`][Flips the bit at index `ui` in `b`. Only required when `B` is an integer type. + The default version of this function is synthesised from other operations above.][[space]]] +[[`eval_gcd(b, cb, cb2)`][`void`][Sets `b` to the greatest common divisor of `cb` and `cb2`. Only required when `B` is an integer type. + The default version of this function is synthesised from other operations above.][[space]]] +[[`eval_lcm(b, cb, cb2)`][`void`][Sets `b` to the least common multiple of `cb` and `cb2`. Only required when `B` is an integer type. + The default version of this function is synthesised from other operations above.][[space]]] +[[`eval_gcd(b, cb, a)`][`void`][Sets `b` to the greatest common divisor of `cb` and `cb2`. Only required when `B` is an integer type. + The type of `a` shall be listed in one of the type lists + `B::signed_types`, `B::unsigned_types` or `B::float_types`. + The default version of this function calls `eval_gcd(b, cb, B(a))`.][[space]]] +[[`eval_lcm(b, cb, a)`][`void`][Sets `b` to the least common multiple of `cb` and `cb2`. Only required when `B` is an integer type. + The type of `a` shall be listed in one of the type lists + `B::signed_types`, `B::unsigned_types` or `B::float_types`. + The default version of this function calls `eval_lcm(b, cb, B(a))`.][[space]]] +[[`eval_gcd(b, a, cb)`][`void`][Sets `b` to the greatest common divisor of `cb` and `a`. Only required when `B` is an integer type. + The type of `a` shall be listed in one of the type lists + `B::signed_types`, `B::unsigned_types` or `B::float_types`. + The default version of this function calls `eval_gcd(b, cb, a)`.][[space]]] +[[`eval_lcm(b, a, cb)`][`void`][Sets `b` to the least common multiple of `cb` and `a`. Only required when `B` is an integer type. + The type of `a` shall be listed in one of the type lists + `B::signed_types`, `B::unsigned_types` or `B::float_types`. + The default version of this function calls `eval_lcm(b, cb, a)`.][[space]]] +[[`eval_powm(b, cb, cb2, cb3)`][`void`][Sets `b` to the result of ['(cb^cb2)%cb3]. + The default version of this function is synthesised from other operations above.][[space]]] +[[`eval_powm(b, cb, cb2, a)`][`void`][Sets `b` to the result of ['(cb^cb2)%a]. + The type of `a` shall be listed in one of the type lists + `B::signed_types`, `B::unsigned_types`. + The default version of this function is synthesised from other operations above.][[space]]] +[[`eval_powm(b, cb, a, cb2)`][`void`][Sets `b` to the result of ['(cb^a)%cb2]. + The type of `a` shall be listed in one of the type lists + `B::signed_types`, `B::unsigned_types`. + The default version of this function is synthesised from other operations above.][[space]]] +[[`eval_powm(b, cb, a, a2)`][`void`][Sets `b` to the result of ['(cb^a)%a2]. + The type of `a` shall be listed in one of the type lists + `B::signed_types`, `B::unsigned_types`. + The default version of this function is synthesised from other operations above.][[space]]] + +[[['Sign manipulation:]]] +[[`eval_abs(b, cb)`][`void`][Set `b` to the absolute value of `cb`. + The default version of this functions assigns `cb` to `b`, and then calls `b.negate()` if + `eval_get_sign(cb) < 0`.][[space]]] +[[`eval_fabs(b, cb)`][`void`][Set `b` to the absolute value of `cb`. + The default version of this functions assigns `cb` to `b`, and then calls `b.negate()` if + `eval_get_sign(cb) < 0`.][[space]]] + +[[['Floating point functions:]]] +[[`eval_fpclassify(cb)`][`int`][Returns one of the same values returned by `std::fpclassify`. Only required when `B` is an floating-point type. + The default version of this function will only test for zero `cb`.][[space]]] +[[`eval_trunc(b, cb)`][`void`][Performs the equivalent operation to `std::trunc` on argument `cb` and stores the result in `b`. Only required when `B` is an floating-point type. + The default version of this function is synthesised from other operations above.][[space]]] +[[`eval_round(b, cb)`][`void`][Performs the equivalent operation to `std::round` on argument `cb` and stores the result in `b`. Only required when `B` is an floating-point type. + The default version of this function is synthesised from other operations above.][[space]]] +[[`eval_exp(b, cb)`][`void`][Performs the equivalent operation to `std::exp` on argument `cb` and stores the result in `b`. Only required when `B` is an floating-point type. + The default version of this function is synthesised from other operations above.][[space]]] +[[`eval_log(b, cb)`][`void`][Performs the equivalent operation to `std::log` on argument `cb` and stores the result in `b`. Only required when `B` is an floating-point type. + The default version of this function is synthesised from other operations above.][[space]]] +[[`eval_log10(b, cb)`][`void`][Performs the equivalent operation to `std::log10` on argument `cb` and stores the result in `b`. Only required when `B` is an floating-point type. + The default version of this function is synthesised from other operations above.][[space]]] +[[`eval_sin(b, cb)`][`void`][Performs the equivalent operation to `std::sin` on argument `cb` and stores the result in `b`. Only required when `B` is an floating-point type. + The default version of this function is synthesised from other operations above.][[space]]] +[[`eval_cos(b, cb)`][`void`][Performs the equivalent operation to `std::cos` on argument `cb` and stores the result in `b`. Only required when `B` is an floating-point type. + The default version of this function is synthesised from other operations above.][[space]]] +[[`eval_tan(b, cb)`][`void`][Performs the equivalent operation to `std::exp` on argument `cb` and stores the result in `b`. Only required when `B` is an floating-point type. + The default version of this function is synthesised from other operations above.][[space]]] +[[`eval_asin(b, cb)`][`void`][Performs the equivalent operation to `std::asin` on argument `cb` and stores the result in `b`. Only required when `B` is an floating-point type. + The default version of this function is synthesised from other operations above.][[space]]] +[[`eval_acos(b, cb)`][`void`][Performs the equivalent operation to `std::acos` on argument `cb` and stores the result in `b`. Only required when `B` is an floating-point type. + The default version of this function is synthesised from other operations above.][[space]]] +[[`eval_atan(b, cb)`][`void`][Performs the equivalent operation to `std::atan` on argument `cb` and stores the result in `b`. Only required when `B` is an floating-point type. + The default version of this function is synthesised from other operations above.][[space]]] +[[`eval_sinh(b, cb)`][`void`][Performs the equivalent operation to `std::sinh` on argument `cb` and stores the result in `b`. Only required when `B` is an floating-point type. + The default version of this function is synthesised from other operations above.][[space]]] +[[`eval_cosh(b, cb)`][`void`][Performs the equivalent operation to `std::cosh` on argument `cb` and stores the result in `b`. Only required when `B` is an floating-point type. + The default version of this function is synthesised from other operations above.][[space]]] +[[`eval_tanh(b, cb)`][`void`][Performs the equivalent operation to `std::tanh` on argument `cb` and stores the result in `b`. Only required when `B` is an floating-point type. + The default version of this function is synthesised from other operations above.][[space]]] +[[`eval_fmod(b, cb, cb2)`][`void`][Performs the equivalent operation to `std::fmod` on arguments `cb` and `cb2`, and store the result in `b`. Only required when `B` is an floating-point type. + The default version of this function is synthesised from other operations above.][[space]]] +[[`eval_pow(b, cb, cb2)`][`void`][Performs the equivalent operation to `std::pow` on arguments `cb` and `cb2`, and store the result in `b`. Only required when `B` is an floating-point type. + The default version of this function is synthesised from other operations above.][[space]]] +[[`eval_atan2(b, cb, cb2)`][`void`][Performs the equivalent operation to `std::atan` on arguments `cb` and `cb2`, and store the result in `b`. Only required when `B` is an floating-point type. + The default version of this function is synthesised from other operations above.][[space]]] ] -The tables above place no ['throws] requirements on any of the operations. It is up to each type modelling this concept to +When the tables above place no ['throws] requirements on an operation, then it is up to each type modelling this concept to decide when or whether throwing an exception is desirable. However, thrown exceptions should always either be the type, or inherit from the type `std::runtime_error`. For example, a floating point type might choose to throw `std::overflow_error` whenever the result of an operation would be infinite, and `std::underflow_error` whenever it would round to zero. diff --git a/include/boost/multiprecision/cpp_int.hpp b/include/boost/multiprecision/cpp_int.hpp index 9a4e771b..dd745e04 100644 --- a/include/boost/multiprecision/cpp_int.hpp +++ b/include/boost/multiprecision/cpp_int.hpp @@ -2149,7 +2149,7 @@ void divide_unsigned_helper(cpp_int_backend* if(y == 0) { - BOOST_THROW_EXCEPTION(std::runtime_error("Integer Division by zero.")); + BOOST_THROW_EXCEPTION(std::overflow_error("Integer Division by zero.")); } // // Find the most significant word of numerator. @@ -2764,66 +2764,6 @@ inline unsigned eval_lsb(const cpp_int_backend::limb_bits; } -template -inline void eval_gcd(cpp_int_backend& result, const cpp_int_backend& a, const cpp_int_backend& b) BOOST_NOEXCEPT_IF(boost::is_void::value) -{ - int shift; - - cpp_int_backend u(a), v(b); - - int s = eval_get_sign(u); - - /* GCD(0,x) := x */ - if(s < 0) - { - u.negate(); - } - else if(s == 0) - { - result = v; - return; - } - s = eval_get_sign(v); - if(s < 0) - { - v.negate(); - } - else if(s == 0) - { - result = u; - return; - } - - /* Let shift := lg K, where K is the greatest power of 2 - dividing both u and v. */ - - unsigned us = eval_lsb(u); - unsigned vs = eval_lsb(v); - shift = (std::min)(us, vs); - eval_right_shift(u, us); - eval_right_shift(v, vs); - - do - { - /* Now u and v are both odd, so diff(u, v) is even. - Let u = min(u, v), v = diff(u, v)/2. */ - if(u.compare(v) > 0) - u.swap(v); - eval_subtract(v, u); - // Termination condition tries not to do a full compare if possible: - if(!v.limbs()[0] && eval_is_zero(v)) - break; - vs = eval_lsb(v); - eval_right_shift(v, vs); - BOOST_ASSERT((v.limbs()[0] & 1)); - BOOST_ASSERT((u.limbs()[0] & 1)); - } - while(true); - - result = u; - eval_left_shift(result, shift); -} - template inline bool eval_bit_test(const cpp_int_backend& val, unsigned index) BOOST_NOEXCEPT { @@ -2884,25 +2824,6 @@ inline void eval_bit_flip(cpp_int_backend& va val.normalize(); } -template -inline void eval_lcm(cpp_int_backend& result, const cpp_int_backend& a, const cpp_int_backend& b) BOOST_NOEXCEPT_IF(boost::is_void::value) -{ - cpp_int_backend t; - eval_gcd(t, a, b); - - if(eval_is_zero(t)) - { - result = static_cast(0); - } - else - { - eval_divide(result, a, t); - eval_multiply(result, b); - } - if(eval_get_sign(result) < 0) - result.negate(); -} - template inline void eval_qr(const cpp_int_backend& x, const cpp_int_backend& y, cpp_int_backend& q, cpp_int_backend& r) BOOST_NOEXCEPT_IF(boost::is_void::value) diff --git a/include/boost/multiprecision/depricated/fixed_int.hpp b/include/boost/multiprecision/depricated/fixed_int.hpp index c12fa3a8..3595f27b 100644 --- a/include/boost/multiprecision/depricated/fixed_int.hpp +++ b/include/boost/multiprecision/depricated/fixed_int.hpp @@ -889,7 +889,7 @@ void divide_unsigned_helper(fixed_int& result, const fixed_int BOOST_FORCEINLINE void eval_divide(cpp_int_backend& result, const cpp_int_backend& o) { if(!*o.limbs()) - BOOST_THROW_EXCEPTION(std::runtime_error("Division by zero.")); + BOOST_THROW_EXCEPTION(std::overflow_error("Division by zero.")); *result.limbs() /= *o.limbs(); result.sign(result.sign() != o.sign()); } @@ -194,7 +194,7 @@ template BOOST_FORCEINLINE void eval_divide(cpp_int_backend& result, const cpp_int_backend& o) { if(!*o.limbs()) - BOOST_THROW_EXCEPTION(std::runtime_error("Division by zero.")); + BOOST_THROW_EXCEPTION(std::overflow_error("Division by zero.")); *result.limbs() /= *o.limbs(); } @@ -202,7 +202,7 @@ template BOOST_FORCEINLINE void eval_modulus(cpp_int_backend& result, const cpp_int_backend& o) { if(!*o.limbs()) - BOOST_THROW_EXCEPTION(std::runtime_error("Division by zero.")); + BOOST_THROW_EXCEPTION(std::overflow_error("Division by zero.")); *result.limbs() %= *o.limbs(); result.sign(result.sign()); } diff --git a/include/boost/multiprecision/detail/integer_ops.hpp b/include/boost/multiprecision/detail/integer_ops.hpp index 4103d81b..ad041533 100644 --- a/include/boost/multiprecision/detail/integer_ops.hpp +++ b/include/boost/multiprecision/detail/integer_ops.hpp @@ -38,6 +38,88 @@ inline Integer eval_integer_modulus(const Backend& x, Integer val) return maybe_abs(result); } +template +inline void eval_gcd(B& result, const B& a, const B& b) +{ + using default_ops::eval_lsb; + using default_ops::eval_is_zero; + using default_ops::eval_get_sign; + + int shift; + + B u(a), v(b); + + int s = eval_get_sign(u); + + /* GCD(0,x) := x */ + if(s < 0) + { + u.negate(); + } + else if(s == 0) + { + result = v; + return; + } + s = eval_get_sign(v); + if(s < 0) + { + v.negate(); + } + else if(s == 0) + { + result = u; + return; + } + + /* Let shift := lg K, where K is the greatest power of 2 + dividing both u and v. */ + + unsigned us = eval_lsb(u); + unsigned vs = eval_lsb(v); + shift = (std::min)(us, vs); + eval_right_shift(u, us); + eval_right_shift(v, vs); + + do + { + /* Now u and v are both odd, so diff(u, v) is even. + Let u = min(u, v), v = diff(u, v)/2. */ + if(u.compare(v) > 0) + u.swap(v); + eval_subtract(v, u); + // Termination condition tries not to do a full compare if possible: + if(eval_is_zero(v)) + break; + vs = eval_lsb(v); + eval_right_shift(v, vs); + } + while(true); + + result = u; + eval_left_shift(result, shift); +} + +template +inline void eval_lcm(B& result, const B& a, const B& b) +{ + typedef typename typename mpl::front::type ui_type; + B t; + eval_gcd(t, a, b); + + if(eval_is_zero(t)) + { + result = static_cast(0); + } + else + { + eval_divide(result, a, t); + eval_multiply(result, b); + } + if(eval_get_sign(result) < 0) + result.negate(); +} + } template diff --git a/include/boost/multiprecision/gmp.hpp b/include/boost/multiprecision/gmp.hpp index b8d290f9..6a21bc86 100644 --- a/include/boost/multiprecision/gmp.hpp +++ b/include/boost/multiprecision/gmp.hpp @@ -570,7 +570,7 @@ template inline void eval_divide(gmp_float& result, const gmp_float& o) { if(eval_is_zero(o)) - BOOST_THROW_EXCEPTION(std::runtime_error("Division by zero.")); + BOOST_THROW_EXCEPTION(std::overflow_error("Division by zero.")); mpf_div(result.data(), result.data(), o.data()); } template @@ -592,7 +592,7 @@ template inline void eval_divide(gmp_float& result, unsigned long i) { if(i == 0) - BOOST_THROW_EXCEPTION(std::runtime_error("Division by zero.")); + BOOST_THROW_EXCEPTION(std::overflow_error("Division by zero.")); mpf_div_ui(result.data(), result.data(), i); } template @@ -622,7 +622,7 @@ template inline void eval_divide(gmp_float& result, long i) { if(i == 0) - BOOST_THROW_EXCEPTION(std::runtime_error("Division by zero.")); + BOOST_THROW_EXCEPTION(std::overflow_error("Division by zero.")); mpf_div_ui(result.data(), result.data(), std::abs(i)); if(i < 0) mpf_neg(result.data(), result.data()); @@ -741,21 +741,21 @@ template inline void eval_divide(gmp_float& a, const gmp_float& x, const gmp_float& y) { if(eval_is_zero(y)) - BOOST_THROW_EXCEPTION(std::runtime_error("Division by zero.")); + BOOST_THROW_EXCEPTION(std::overflow_error("Division by zero.")); mpf_div(a.data(), x.data(), y.data()); } template inline void eval_divide(gmp_float& a, const gmp_float& x, unsigned long y) { if(y == 0) - BOOST_THROW_EXCEPTION(std::runtime_error("Division by zero.")); + BOOST_THROW_EXCEPTION(std::overflow_error("Division by zero.")); mpf_div_ui(a.data(), x.data(), y); } template inline void eval_divide(gmp_float& a, const gmp_float& x, long y) { if(y == 0) - BOOST_THROW_EXCEPTION(std::runtime_error("Division by zero.")); + BOOST_THROW_EXCEPTION(std::overflow_error("Division by zero.")); if(y < 0) { mpf_div_ui(a.data(), x.data(), -y); @@ -768,14 +768,14 @@ template inline void eval_divide(gmp_float& a, unsigned long x, const gmp_float& y) { if(eval_is_zero(y)) - BOOST_THROW_EXCEPTION(std::runtime_error("Division by zero.")); + BOOST_THROW_EXCEPTION(std::overflow_error("Division by zero.")); mpf_ui_div(a.data(), x, y.data()); } template inline void eval_divide(gmp_float& a, long x, const gmp_float& y) { if(eval_is_zero(y)) - BOOST_THROW_EXCEPTION(std::runtime_error("Division by zero.")); + BOOST_THROW_EXCEPTION(std::overflow_error("Division by zero.")); if(x < 0) { mpf_ui_div(a.data(), -x, y.data()); @@ -1278,7 +1278,7 @@ inline void eval_multiply(gmp_int& t, const gmp_int& o) inline void eval_divide(gmp_int& t, const gmp_int& o) { if(eval_is_zero(o)) - BOOST_THROW_EXCEPTION(std::runtime_error("Division by zero.")); + BOOST_THROW_EXCEPTION(std::overflow_error("Division by zero.")); mpz_tdiv_q(t.data(), t.data(), o.data()); } inline void eval_modulus(gmp_int& t, const gmp_int& o) @@ -1304,7 +1304,7 @@ inline void eval_modulus(gmp_int& t, unsigned long i) inline void eval_divide(gmp_int& t, unsigned long i) { if(i == 0) - BOOST_THROW_EXCEPTION(std::runtime_error("Division by zero.")); + BOOST_THROW_EXCEPTION(std::overflow_error("Division by zero.")); mpz_tdiv_q_ui(t.data(), t.data(), i); } inline void eval_add(gmp_int& t, long i) @@ -1334,7 +1334,7 @@ inline void eval_modulus(gmp_int& t, long i) inline void eval_divide(gmp_int& t, long i) { if(i == 0) - BOOST_THROW_EXCEPTION(std::runtime_error("Division by zero.")); + BOOST_THROW_EXCEPTION(std::overflow_error("Division by zero.")); mpz_tdiv_q_ui(t.data(), t.data(), std::abs(i)); if(i < 0) mpz_neg(t.data(), t.data()); @@ -1390,7 +1390,7 @@ inline void eval_multiply(gmp_int& t, const gmp_int& p, const gmp_int& o) inline void eval_divide(gmp_int& t, const gmp_int& p, const gmp_int& o) { if(eval_is_zero(o)) - BOOST_THROW_EXCEPTION(std::runtime_error("Division by zero.")); + BOOST_THROW_EXCEPTION(std::overflow_error("Division by zero.")); mpz_tdiv_q(t.data(), p.data(), o.data()); } inline void eval_modulus(gmp_int& t, const gmp_int& p, const gmp_int& o) @@ -1416,7 +1416,7 @@ inline void eval_modulus(gmp_int& t, const gmp_int& p, unsigned long i) inline void eval_divide(gmp_int& t, const gmp_int& p, unsigned long i) { if(i == 0) - BOOST_THROW_EXCEPTION(std::runtime_error("Division by zero.")); + BOOST_THROW_EXCEPTION(std::overflow_error("Division by zero.")); mpz_tdiv_q_ui(t.data(), p.data(), i); } inline void eval_add(gmp_int& t, const gmp_int& p, long i) @@ -1446,7 +1446,7 @@ inline void eval_modulus(gmp_int& t, const gmp_int& p, long i) inline void eval_divide(gmp_int& t, const gmp_int& p, long i) { if(i == 0) - BOOST_THROW_EXCEPTION(std::runtime_error("Division by zero.")); + BOOST_THROW_EXCEPTION(std::overflow_error("Division by zero.")); mpz_tdiv_q_ui(t.data(), p.data(), std::abs(i)); if(i < 0) mpz_neg(t.data(), t.data()); @@ -1914,7 +1914,7 @@ inline void eval_multiply(gmp_rational& t, const gmp_rational& o) inline void eval_divide(gmp_rational& t, const gmp_rational& o) { if(eval_is_zero(o)) - BOOST_THROW_EXCEPTION(std::runtime_error("Division by zero.")); + BOOST_THROW_EXCEPTION(std::overflow_error("Division by zero.")); mpq_div(t.data(), t.data(), o.data()); } inline void eval_add(gmp_rational& t, const gmp_rational& p, const gmp_rational& o) @@ -1932,7 +1932,7 @@ inline void eval_multiply(gmp_rational& t, const gmp_rational& p, const gmp_rati inline void eval_divide(gmp_rational& t, const gmp_rational& p, const gmp_rational& o) { if(eval_is_zero(o)) - BOOST_THROW_EXCEPTION(std::runtime_error("Division by zero.")); + BOOST_THROW_EXCEPTION(std::overflow_error("Division by zero.")); mpq_div(t.data(), p.data(), o.data()); } diff --git a/include/boost/multiprecision/rational_adapter.hpp b/include/boost/multiprecision/rational_adapter.hpp index 06fe7eb1..57c4f6d4 100644 --- a/include/boost/multiprecision/rational_adapter.hpp +++ b/include/boost/multiprecision/rational_adapter.hpp @@ -154,7 +154,7 @@ inline void eval_divide(rational_adapter& result, const rational_ada using default_ops::eval_is_zero; if(eval_is_zero(o)) { - BOOST_THROW_EXCEPTION(std::runtime_error("Divide by zero.")); + BOOST_THROW_EXCEPTION(std::overflow_error("Divide by zero.")); } result.data() /= o.data(); } diff --git a/include/boost/multiprecision/tommath.hpp b/include/boost/multiprecision/tommath.hpp index 0068ffde..6eb8e973 100644 --- a/include/boost/multiprecision/tommath.hpp +++ b/include/boost/multiprecision/tommath.hpp @@ -378,11 +378,17 @@ inline void eval_multiply(tommath_int& t, const tommath_int& o) } inline void eval_divide(tommath_int& t, const tommath_int& o) { + using default_ops::eval_is_zero; tommath_int temp; + if(eval_is_zero(o)) + BOOST_THROW_EXCEPTION(std::overflow_error("Integer division by zero")); detail::check_tommath_result(mp_div(&t.data(), const_cast< ::mp_int*>(&o.data()), &t.data(), &temp.data())); } inline void eval_modulus(tommath_int& t, const tommath_int& o) { + using default_ops::eval_is_zero; + if(eval_is_zero(o)) + BOOST_THROW_EXCEPTION(std::overflow_error("Integer division by zero")); bool neg = eval_get_sign(t) < 0; bool neg2 = eval_get_sign(o) < 0; detail::check_tommath_result(mp_mod(&t.data(), const_cast< ::mp_int*>(&o.data()), &t.data())); @@ -455,11 +461,17 @@ inline void eval_multiply(tommath_int& t, const tommath_int& p, const tommath_in } inline void eval_divide(tommath_int& t, const tommath_int& p, const tommath_int& o) { + using default_ops::eval_is_zero; tommath_int d; + if(eval_is_zero(o)) + BOOST_THROW_EXCEPTION(std::overflow_error("Integer division by zero")); detail::check_tommath_result(mp_div(const_cast< ::mp_int*>(&p.data()), const_cast< ::mp_int*>(&o.data()), &t.data(), &d.data())); } inline void eval_modulus(tommath_int& t, const tommath_int& p, const tommath_int& o) { + using default_ops::eval_is_zero; + if(eval_is_zero(o)) + BOOST_THROW_EXCEPTION(std::overflow_error("Integer division by zero")); bool neg = eval_get_sign(p) < 0; bool neg2 = eval_get_sign(o) < 0; detail::check_tommath_result(mp_mod(const_cast< ::mp_int*>(&p.data()), const_cast< ::mp_int*>(&o.data()), &t.data())); diff --git a/test/test_arithmetic.cpp b/test/test_arithmetic.cpp index 71e49d19..e15efa6a 100644 --- a/test/test_arithmetic.cpp +++ b/test/test_arithmetic.cpp @@ -245,7 +245,7 @@ void test_integer_ops(const boost::mpl::int_ @@ -636,7 +636,7 @@ void test_float_ops(const boost::mpl::int_