Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!bloom-beacon!think!ames!amdahl!dlb!dana!rap From: rap@dana.UUCP (Rob Peck) Newsgroups: comp.sys.amiga Subject: Bug in audiotools Message-ID: <221@dana.UUCP> Date: Mon, 14-Sep-87 18:40:12 EDT Article-I.D.: dana.221 Posted: Mon Sep 14 18:40:12 1987 Date-Received: Wed, 16-Sep-87 06:42:02 EDT Organization: Dana Computer, Inc., Sunnyvale, CA Lines: 26 Keywords: audio tools bug I found a bug in the latest release of my audiotools... it has to do with the calculation of the time to play a waveform. Basically, any waveform that is to play more than 1.18 seconds (1180 thousandths of a second) will get an arithmetic overflow. I was trying to retain the largest number of digits of precision possible, so specified the duration in 1000ths of a second. Part of the duration calculation has the following calculation: ((3579545 * duration)/1000) and this is what overflows a 32-bit value. To fix the problem, use the following calculation instead: long value; /* resultant value */ long frac_part; /* fractional part of the duration value in 1000ths */ long int_part; /* integer part of the duration value, in seconds */ int_part = duration/1000; /* truncates to an integer */ frac_part = duration - (int_part * 1000); value = 3579545 * int_part + (3579545 * frac_part)/1000; This gives the same value, but does not result in an arithmetic overflow, while retaining the number of significant digits that you started with. Rob Peck ...ihnp4!hplabs!dana!rap