Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!pacbell.com!ucsd!nosc!humu!pegasus!pinhead!todd From: todd@pinhead.pegasus.com (Todd Ogasawara) Newsgroups: comp.lang.perl Subject: UNIX Perl vs. DOS Perl (arithmetic)? Message-ID: <1991May23.221206.12903@pinhead.pegasus.com> Date: 23 May 91 22:12:06 GMT Organization: Hawaii Medical Service Association Lines: 47 I wrote a little program that takes data files of a particular format (fixed record, no delimiters) and calculates various totals to compare to a trailer record in that file. The program works fine when I run it using Perl 4.0 PL03 under UNIX (ISC 2.2, System V/386 R3). However, I get wildly different results when I run the same program (and using the same data file) under the DOS version of Perl (3.0 PL41). The outputs are attached below. Perl 4.0 PL03 under ISC 2.2 *** FROM TRAILER RECORD *** Total records 26 Total charges 1991.60 Total adjustments -363.23 Total allowances 880.91 *** FROM REFERENCE RECORDS *** Total records 26 <== Trailer and calculated figure match Total charges 1991.60 <== Trailer and calculated figure match Total adjustments -363.23 <== Trailer and calculated figure match Total allowances 880.91 <== Trailer and calculated figure match Perl 3.0 PL41 under MS-DOS 3.3 *** FROM TRAILER RECORD *** Total records 26 Total charges 199.16 Total adjustments -36.32 Total allowances 88.09 *** FROM REFERENCE RECORDS *** Total records 26 <== Trailer and calculated figure match Total charges 199.13 <== ERROR of -0.03000000000000114 Total adjustments -36.29 <== ERROR of 0.03000000000000114 Total allowances 88.04 <== ERROR of -0.04999999999999716 I checked the data file I brought down to DOS and confirmed that it is identical to the one I used on the UNIX system. All I am doing is 'substr' segments of 160 byte long records and accumulating totals. It works fine under UNIX but fails miserably in the DOS version. Any ideas? I used a MS-DOS based program that I hoped to replace with the Perl program to double check things under DOS. The old program returns results that agree with the UNIX Perl program. -- Todd Ogasawara ::: Hawaii Medical Service Association Internet ::: todd@pinhead.pegasus.com Telephone ::: (808) 536-9162 ext. 7