Subject: [Boost-bugs] [Boost C++ Libraries] #4847: tweaking the memoized fibonnacci to produce > 40 number give strange results
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-11-12 15:58:36
#4847: tweaking the memoized fibonnacci to produce > 40 number give strange
results
---------------------------------------------------------+------------------
Reporter: sylvain foubert <sylvain.foubert@â¦> | Owner: joaquin
Type: Bugs | Status: new
Milestone: To Be Determined | Component: flyweight
Version: Boost 1.44.0 | Severity: Problem
Keywords: example fibonacci |
---------------------------------------------------------+------------------
I changed the integer type for numbers from int to unsigned long for
higher precision and I got erroneous computed values after F(47) :
F(46)=1836311903
F(47)=2971215073
F(48)=512559680
F(49)=3483774753
{{{
typedef flyweight<key_value<unsigned long,compute_fibonacci>,no_tracking>
fibonacci;
struct compute_fibonacci:private boost::noncopyable
{
compute_fibonacci(unsigned long n):
result(n==0?0:n==1?1:fibonacci(n-2).get()+fibonacci(n-1).get())
{}
operator unsigned long()const{return result;}
unsigned long result;
};
}}}
Internal bug or unprecautious use of the API ?
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/4847> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:04 UTC