Subject: Re: eap(4) and ess(4) and mixer volume values
To: None <tech-kern@netbsd.org, tron@zhadum.de>
From: Wolfgang Solfrank <ws@tools.de>
List: tech-kern
Date: 08/16/2000 15:31:19
Hi,

> Ok, here is my fix:

[...]

> -#define TO_OSSVOL(x) ((x) * 100 / 255)
> -#define FROM_OSSVOL(x) (((x) > 100 ? 100 : (x)) * 255 / 100)
> +#define TO_OSSVOL(x) ((int)(((x) * 100.0 / 255.0) + 0.5))
> +#define FROM_OSSVOL(x) ((int)((((x) > 100 ? 100 : (x)) * 255.0 / 100.0) + 0.5))

Hmm, everyone on this planet I know would write this as

#define	TO_OSSVOL(x)	(((x) * 100 + 127) / 255)
#define	FROM_OSSVOL(x)	((((x) > 100 ? 100 : (x)) * 255 + 50) / 100)

which avoids the usage of floating point computation.

Ciao,
Wolfgang
-- 
ws@TooLs.DE     Wolfgang Solfrank, TooLs GmbH 	+49-228-985800