summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorAlexandre Ratchov <ratchov@cvs.openbsd.org>2018-11-07 21:22:35 +0000
committerAlexandre Ratchov <ratchov@cvs.openbsd.org>2018-11-07 21:22:35 +0000
commit16249f116be5fa7f97dd130a93b8132ca2359a46 (patch)
treea873aadae9a584f934d32376cab5395ae28cac79 /usr.bin
parenta4056e77cbb26f6a514e69738bd98681be4df918 (diff)
Fix clipping during float to integer conversions.
From Jari Vetoniemi <mailroxas at gmail.com>. Thanks!
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/aucat/dsp.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/usr.bin/aucat/dsp.c b/usr.bin/aucat/dsp.c
index c231fc2f7db..0ca1f6e20d3 100644
--- a/usr.bin/aucat/dsp.c
+++ b/usr.bin/aucat/dsp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dsp.c,v 1.12 2018/09/18 04:29:58 miko Exp $ */
+/* $OpenBSD: dsp.c,v 1.13 2018/11/07 21:22:34 ratchov Exp $ */
/*
* Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org>
*
@@ -660,11 +660,11 @@ f32_to_adata(unsigned int x)
* 31 - (BITS - 1) - (e - 127)
*
* to ensure output is in the 0..(2^BITS)-1 range, the minimum
- * shift is 31 - (BITS - 1), and maximum shift is 31
+ * shift is 31 - (BITS - 1) + 1, and maximum shift is 31
*/
if (e < 127 - (ADATA_BITS - 1))
y = 0;
- else if (e > 127)
+ else if (e >= 127)
y = ADATA_UNIT - 1;
else
y = m >> (127 + (32 - ADATA_BITS) - e);