Java Debug

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Fred Ho
    New Member
    • Oct 2007
    • 18

    #1

    Java Debug

    How to debug the program:
    the Netbean say it loss precision, as a beginner of java, I am looking for the kindly help... thanks!

    public synchronized void compress(int threshold, int ratio) {
    // Loop through all audio data in the buffer

    for (int i=0; i<this.dataLeng th; i++) {
    int temp = Math.round(buff er[i]);
    // if clipping found restricting the range from -128 to 127 (8 bit)
    if (temp < threshold) buffer[i] = threshold;

    else if (temp > threshold ) buffer[i] = (temp-threshold)/(ratio+threshol d);
    else buffer[i] = (byte)temp;
    }

    }
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Is buffer an array of doubles? If so, that's where the compiler warning comes from:
    when you implicitely convert a double to an int you lose the digits in the fraction
    part of the double value. The compiler warns you for that.

    kind regards,

    Jos

    Comment

    Working...