Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 12 Mar 2023 13:12:24 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 270154] bc freezes evaluating cbrt(0.01)
Message-ID:  <bug-270154-227@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D270154

            Bug ID: 270154
           Summary: bc freezes evaluating cbrt(0.01)
           Product: Base System
           Version: 13.1-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: igor@kolesnik.es

bin/bc enters an infinite loop while evaluating the cube-root of 0.01

bin/bc -l -e 'cbrt(0.1)'
returns .46415888336127788924 (which is expected)

bin/bc -l -e 'cbrt(0.01)'
freezes

Looking at the definition of root(x,n) in lib2.bc the following loop never
exits

        while(r!=3Dq){
                r=3Dq
                q=3D(p*r+x/r^p)/n
        }

A simple hack makes the cbrt function working.

        while(abs(r-q)>0.000001){
                r=3Dq
                q=3D(p*r+x/r^p)/n
        }

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-270154-227>