Article View: comp.lang.pascal.borland
Article #404Re: Help, Help, Help BCD
From: Ralf Rochow
Date: Sat, 19 Dec 1998 00:00
Date: Sat, 19 Dec 1998 00:00
183 lines
7790 bytes
7790 bytes
--------------5D0301541D54DCD2BA47A41F Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi Robert, when searching the internet I found a page which discused a BCD-Unit called AJCBCD. Useing FTP-Search the only server with this file is ftp.ceu.fi.udc.es on /home/ftp/development/pascal but I'm not able to download. ( perhaps I have rights to read a directory but not to read files or me ftp-connect does not work ). Do you know other locations of this file or other files with a BCD-Unit. Thank you Robert for your help Ralf Robert AH Prins wrote: > In article <367A4B0E.CA324425@gisma.de>, > r.rochow@gisma.de wrote: > > Hi Robert, > > > > thinks about a medium list ( a customer having his acount for 5 years with 20 > > movements each month has about 1200 movments ) of cash-acounts, which are to > > be calculated for a saldo. So in most currencys the fractional part has 2 > > digits and range from x,00 to x,99. So 0,25 or 0,50 are ( negative ) powers of > > 2 they can be represented in biniary values ( double, extendet ) exactly. > > Values like x,49 or x,96 can't be represendet in double-datatypes -> they > > would result in something like x,489982938739 of x,960021232313. Add two of > > this values and then rounding the result should bring up the correct value. > > But adding hundreds or thousands of this values and then rounding the result > > is a mistake. > > Unfortunately I am all to aware of this, at Willis we have to apportion > premiums over many (dozens of) underwriters, and it's a nightmare. All of out > batch programs actually abend if there are control differences, even if only > 1 pence! > > As some posters wrote, use COMP (-2^63 .. 2^63-1), or consider splitting up > your amounts into separate totals for the integer & fractional parts. It > would extend your range to 2,147,483,647.99 (longint) or > 9,223,372,036,854,775,807.99 (comp), which might be enough, and which would > certainly be faster than using BCD. > > > The workaround is to round the value each time an operation is done. > > Very time consuming, especially if you're using the FPU as every rounding will > save/change/restore the controlword when you're using pure Pascal. > > > In my newer c++ programs I use a BCD-Libray ( Money++ from roguewave ) > > and I have no problems with rounding error. > > > > So this is the first reason I'm looking for a BCD-Unit for pascal. > > Never considered writing some small C++ programs and looking at the generated > code in this BCD library with debug or IDA? > > > The second reason is that I get this values from a ISAM-Database and put the > > results to a database ( i use Btrieve 6.15 ). This database is able to deal > > with BCD-Values directly. > > > > Do you have a good BCD-lib/unit or information where get a good BCD-lib/unit > > please let me know. > > There are a few long-number units available on the pages of some of the > regular posters in comp.lang.pascal.borland. > > Robert > -- > Robert AH Prins > prinsra@williscorroon.com > > -----------== Posted via Deja News, The Discussion Network ==---------- > http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own --------------5D0301541D54DCD2BA47A41F Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit <HTML> Hi Robert, <P>when searching the internet I found a page which discused a BCD-Unit called AJCBCD. Useing FTP-Search the only server with this file is <A HREF="http://ftpsearch.lycos.com/cgi-bin/search?type=Navigate&query=ftp.ceu.fi.udc.es/">ftp.ceu.fi.udc.es</A> on <A HREF="http://ftpsearch.lycos.com/cgi-bin/search?type=Navigate&query=ftp.ceu.fi.udc.es/home/ftp/development/pascal">/home/ftp/development/pascal</A> but I'm not able to download. ( perhaps I have rights to read a directory but not to read files or me ftp-connect does not work ). Do you know other locations of this file or other files with a BCD-Unit. <P>Thank you Robert for your help <P>Ralf <BR> <BR> <BR> <P>Robert AH Prins wrote: <BLOCKQUOTE TYPE=CITE>In article <367A4B0E.CA324425@gisma.de>, <BR> r.rochow@gisma.de wrote: <BR>> Hi Robert, <BR>> <BR>> thinks about a medium list ( a customer having his acount for 5 years with 20 <BR>> movements each month has about 1200 movments ) of cash-acounts, which are to <BR>> be calculated for a saldo. So in most currencys the fractional part has 2 <BR>> digits and range from x,00 to x,99. So 0,25 or 0,50 are ( negative ) powers of <BR>> 2 they can be represented in biniary values ( double, extendet ) exactly. <BR>> Values like x,49 or x,96 can't be represendet in double-datatypes -> they <BR>> would result in something like x,489982938739 of x,960021232313. Add two of <BR>> this values and then rounding the result should bring up the correct value. <BR>> But adding hundreds or thousands of this values and then rounding the result <BR>> is a mistake. <P>Unfortunately I am all to aware of this, at Willis we have to apportion <BR>premiums over many (dozens of) underwriters, and it's a nightmare. All of out <BR>batch programs actually abend if there are control differences, even if only <BR>1 pence! <P>As some posters wrote, use COMP (-2^63 .. 2^63-1), or consider splitting up <BR>your amounts into separate totals for the integer & fractional parts. It <BR>would extend your range to 2,147,483,647.99 (longint) or <BR>9,223,372,036,854,775,807.99 (comp), which might be enough, and which would <BR>certainly be faster than using BCD. <P>> The workaround is to round the value each time an operation is done. <P>Very time consuming, especially if you're using the FPU as every rounding will <BR>save/change/restore the controlword when you're using pure Pascal. <P>> In my newer c++ programs I use a BCD-Libray ( Money++ from roguewave ) <BR>> and I have no problems with rounding error. <BR>> <BR>> So this is the first reason I'm looking for a BCD-Unit for pascal. <P>Never considered writing some small C++ programs and looking at the generated <BR>code in this BCD library with debug or IDA? <P>> The second reason is that I get this values from a ISAM-Database and put the <BR>> results to a database ( i use Btrieve 6.15 ). This database is able to deal <BR>> with BCD-Values directly. <BR>> <BR>> Do you have a good BCD-lib/unit or information where get a good BCD-lib/unit <BR>> please let me know. <P>There are a few long-number units available on the pages of some of the <BR>regular posters in comp.lang.pascal.borland. <P>Robert <BR>-- <BR>Robert AH Prins <BR>prinsra@williscorroon.com <P>-----------== Posted via Deja News, The Discussion Network ==---------- <BR><A HREF="http://www.dejanews.com/">http://www.dejanews.com/</A> Search, Read, Discuss, or Start Your Own</BLOCKQUOTE> </HTML> --------------5D0301541D54DCD2BA47A41F--
Technical Details
Message-ID:
<367BEF7E.1A8C402A@gisma.de>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<36782716.D160ADCD@gisma.de> <75aumk$hj6$1@nnrp1.dejanews.com> <367A4B0E.CA324425@gisma.de> <75dvja$4cd$1@nnrp1.dejanews.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 108ebd,497dcada11896622 X-Google-Attributes: gid108ebd,public X-Google-Thread: 111659,743ddf2b86ac5133 X-Google-Attributes: gid111659,public From: Ralf Rochow <r.rochow@gisma.de> Subject: Re: Help, Help, Help BCD Date: 1998/12/19 Message-ID: <367BEF7E.1A8C402A@gisma.de> X-Deja-AN: 423996099 References: <36782716.D160ADCD@gisma.de> <75aumk$hj6$1@nnrp1.dejanews.com> <367A4B0E.CA324425@gisma.de> <75dvja$4cd$1@nnrp1.dejanews.com> Content-Type: multipart/alternative; boundary="------------5D0301541D54DCD2BA47A41F" Organization: GISMA mbH, Coburg Mime-Version: 1.0 Reply-To: r.rochow@gisma.de Newsgroups: comp.lang.pascal.borland,borland.public.turbopascal