Re: [linux-audio-dev] Converting float to int

New Message Reply About this list Date view Thread view Subject view Author view Other groups

Subject: Re: [linux-audio-dev] Converting float to int
From: Steve Harris (S.W.Harris_AT_ecs.soton.ac.uk)
Date: Mon Oct 29 2001 - 18:59:14 EET


On Mon, Oct 29, 2001 at 11:23:44AM -0500, Paul Davis wrote:
> >You still need to clamp output to [SHRT_MIN,SHRT_MAX], otherwise you might
> >get overflow.
>
> if you have to clamp, is it worth it? if input is -1..1.0, how the
> output ever overflow?

Well, I was assuming that it was really +-1.0f is 0dB(internal), so >1.0
or <-1.0 is possible, and I though that SHRT_MIN != -SHRT_MAX (though K&R
seem to disagree, pp. 257). I guess I've forgotten how 2's complement
works.

- Steve


New Message Reply About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b28 : Mon Oct 29 2001 - 18:56:02 EET