Opened 9 years ago
Closed 9 years ago
#8798 closed Bugs (fixed)
pow(cpp_dec_float_type(0), cpp_dec_float_type(n)) != 0 for n > 1
Reported by: | Owned by: | John Maddock | |
---|---|---|---|
Milestone: | To Be Determined | Component: | multiprecision |
Version: | Boost Development Trunk | Severity: | Problem |
Keywords: | Cc: |
Description
The overload of 'pow' taking both arguments of number<cpp_dec_float<...>> gives a wrong answer when the base == 0 and the exponent > 1.
eg.
using T = cpp_dec_float_50; assert( pow(T(0), T(2)) == 0 ); // Failure
Tested against svn #84980 with clang (Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn)) target: x86_64-apple-darwin12.4.0 with: -std=c++11 -stdlib=libc++
Attachments (2)
Change History (4)
by , 9 years ago
Attachment: | boost_multiprecision_power_demo.cpp added |
---|
by , 9 years ago
Attachment: | boost_multiprecision_power_demo.2.cpp added |
---|
Demonstration of the error - without annoyance, please remove previous
comment:1 by , 9 years ago
Output of the attached code:
pow(0, 0) = 1 pow(0, 1) = 0 pow(0, 2) = 0 pow(1, 0) = 1 pow(1, 1) = 1 pow(1, 2) = 1 pow(2, 0) = 1 pow(2, 1) = 2 pow(2, 2) = 4 pow(0, 0) = 1 pow(0, 1) = 0 pow(0, 2) = 1 - Unexpected! pow(1, 0) = 1 pow(1, 1) = 1 pow(1, 2) = 1 pow(2, 0) = 1 pow(2, 1) = 2 pow(2, 2) = 4 pow(0, 0) = 1 pow(0, 1) = 0 pow(0, 2) = 1 - Unexpected! pow(1, 0) = 1 pow(1, 1) = 1 pow(1, 2) = 1 pow(2, 0) = 1 pow(2, 1) = 2 pow(2, 2) = 4 pow(0, 0) = 1 pow(0, 1) = 0 pow(0, 2) = 1 - Unexpected! pow(1, 0) = 1 pow(1, 1) = 1 pow(1, 2) = 1 pow(2, 0) = 1 pow(2, 1) = 2 pow(2, 2) = 4
comment:2 by , 9 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
Demonstration of the error