Article View: alt.comp.lang.learn.c-c++
Article #588Re: High-precision fixed point math
From: B Summers .com
Date: Wed, 18 Sep 2002 03:56
Date: Wed, 18 Sep 2002 03:56
38 lines
2835 bytes
2835 bytes
<cough>...array...<cough>.... "Mike K" <mkipper@rogers.com> wrote in message news:w8Rh9.77700$561.55900@news02.bloor.is.net.cable.rogers.com... > Hi, > > To start off, yes this is a school question. The question is as follows: > Write a C++ program to calculate and print the square root of an integer to > 40 decimal points. > To me, this seems like a Newton's Method type problem, except for the fact > that my computer can't do more than MSVC++'s 80-bit/10-byte long double. > So, I was thinking of writing a template class which holds BCD number > information in nibbles (full bytes for now, optimize later). Then, math is > performed through the nibble array. > Is this sane? Is there a better way to do it? I don't want to waste my time > reinventing the wheel, if there's already a better answer out there. > I did find, through my travels, a library called BigInt.h, which kind of > implements the same kind of idea: > > #define BIGINT_TOTAL_BITS 128 // Produces 38 decimal digits > #define BIGINT_BASE_BITS 32 // Number of bits in base type > #define BIGINTSIZE (BIGINT_TOTAL_BITS / BIGINT_BASE_BITS) > typedef unsigned long BIGINT_BASE; // The base type. > public: > BIGINT_BASE data[BIGINTSIZE]; /* Little endian data */ > > But I couldn't get it to work properly. > > Thanks for your help! > > Michael > ----- > > >
Technical Details
Message-ID:
<wPSh9.79309$561.72427@news02.bloor.is.net.cable.rogers.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.tele.dk!small.news.tele.dk!213.56.195.71!fr.usenet-edu.net!usenet-edu.net!proxad.net!proxad.net!news-hub.cableinet.net!blueyonder!newsfeeds-atl1.usenetserver.com!newsfeeds-atl2!news.webusenet.com!news03.bloor.is.net.cable.rogers.com!news02.bloor.is.net.cable.rogers.com.POSTED!not-for-mailReferences:
<w8Rh9.77700$561.55900@news02.bloor.is.net.cable.rogers.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 109fba,951da3994a2133ff X-Google-Attributes: gid109fba,public X-Google-Thread: 102541,951da3994a2133ff X-Google-Attributes: gid102541,public X-Google-Thread: 114592,951da3994a2133ff X-Google-Attributes: gid114592,public X-Google-ArrivalTime: 2002-09-17 21:03:44 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.tele.dk!small.news.tele.dk!213.56.195.71!fr.usenet-edu.net!usenet-edu.net!proxad.net!proxad.net!news-hub.cableinet.net!blueyonder!newsfeeds-atl1.usenetserver.com!newsfeeds-atl2!news.webusenet.com!news03.bloor.is.net.cable.rogers.com!news02.bloor.is.net.cable.rogers.com.POSTED!not-for-mail From: "B Summers" <<nospam>@<nospam>.com> Newsgroups: alt.comp.lang.learn.c-c++,borland.public.cppbuilder.students,comp.lang.c++ References: <w8Rh9.77700$561.55900@news02.bloor.is.net.cable.rogers.com> Subject: Re: High-precision fixed point math Lines: 40 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300 Message-ID: <wPSh9.79309$561.72427@news02.bloor.is.net.cable.rogers.com> Date: Wed, 18 Sep 2002 03:56:12 GMT NNTP-Posting-Host: 24.42.221.54 X-Complaints-To: abuse@rogers.com X-Trace: news02.bloor.is.net.cable.rogers.com 1032321372 24.42.221.54 (Tue, 17 Sep 2002 23:56:12 EDT) NNTP-Posting-Date: Tue, 17 Sep 2002 23:56:12 EDT