Boost logo

Boost :

From: Sérgio Vale e Pace (svpace.forum_at_[hidden])
Date: 2005-01-28 07:13:39


not exactlly, sometimes you get the 1 difference correctly so, you
will introduce an error for such cases, and on some compillers (bcc)
for some cases you get an error because it don´t know which version to
instantiate Sqrt<N,X,XP1,XP1> or Sqrt<N,X,X,XP1>

On Thu, 27 Jan 2005 22:55:49 -0500, Jason Hise <chaos_at_[hidden]> wrote:
> Would the following work in all cases? My assumption is that if an
> oscillation is going to occur, the two numbers will always be off by
> exactly one.
>
> template < unsigned int N, unsigned int X = 1, unsigned int X2 = ( X + N
> / X ) / 2, unsigned int XP1 = X + 1 >
> struct Sqrt
> {
> enum ValueStorage
> {
> Value = typename Sqrt < N, X2 > :: Value
> };
> };
>
> template < unsigned int N, unsigned int X, unsigned int XP1 >
> struct Sqrt < N, X, X, XP1 >
> {
> enum ValueStorage
> {
> Value = X
> };
> };
>
> template < unsigned int N, unsigned int X, unsigned int XP1 >
> struct Sqrt < N, X, XP1, XP1 >
> {
> enum ValueStorage
> {
> Value = X
> };
> };
>
> -Jason
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk