rap@dana.UUCP (Rob Peck) (09/15/87)
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