Modify

Ticket #8798 (closed Bugs: fixed)

Opened 10 months ago

Last modified 10 months ago

pow(cpp_dec_float_type(0), cpp_dec_float_type(n)) != 0 for n > 1

Reported by: Jan Bouwer <JBouwer@…> Owned by: johnmaddock
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

boost_multiprecision_power_demo.cpp Download (2.7 KB) - added by Jan Bouwer <JBouwer@…> 10 months ago.
Demonstration of the error
boost_multiprecision_power_demo.2.cpp Download (2.7 KB) - added by Jan Bouwer <JBouwer@…> 10 months ago.
Demonstration of the error - without annoyance, please remove previous

Change History

Changed 10 months ago by Jan Bouwer <JBouwer@…>

Demonstration of the error

Changed 10 months ago by Jan Bouwer <JBouwer@…>

Demonstration of the error - without annoyance, please remove previous

comment:1 Changed 10 months ago by Jan Bouwer <JBouwer@…>

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 Changed 10 months ago by johnmaddock

  • Status changed from new to closed
  • Resolution set to fixed

(In [84997]) Fix bug in eval_pow that causes 0N to be none-zero. Fixes #8798.

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.