逐渐下溢程序的表示 [英] Representation of a Gradual underflow program

查看:208
本文介绍了逐渐下溢程序的表示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读的是关于逐渐下溢的概念,以及它在音乐行业中的重要性。逐渐溢出在音乐中的应用



我很好理解溢出缓冲区的问题, t知道如何表示下溢。



你能给我一个例子(一个程序最好是c或c ++),如同计算机如何处理逐渐下溢?



考虑使用科学计数法,在这种计数法中,你有(说)10位精度和指数,范围从-99到99。



在正常情况下,你把一切都视为科学记数法,所以如果你想代表1000,则表示为1e3 - 也就是1 * 10 3



现在,考虑一个像1.234e- 102。您可以表示的最小指数是-99。因此,如果你以最简单的方式做你的工作,你只是简单地说,因为它的指数小于这个指数,它只是0.这将是快速下溢。



在IEEE 754(和相关标准)中,您可以将其存储为(实质上)0.001234 * 10 -99 。在这样做时,与指数在-99 ... 99范围内的正常数字相比,可能会丢失一些精度。另一方面,如果您将其舍入为零,则会失去 less ,因为它的指数小于-99。事实上,在这种情况下,它以4个有效数字开始,并且如所表示的它保留所有4个有效数字。



在计算机上,数字以二进制表示,当转换为十进制时,有效数字的数字和/或指数的最大范围不是圆的,但是相同的基本思想适用 - 当我们有一个数字太小而不能以正常格式表示时,我们仍然可以存储它

可以的最小指数,但也包括一些前导零。



这会导致一个难题:数字通常存储在称为规范化形式。 有效数部分通过向左移位直到第一个数字为1(记住,因为它是二进制的,它只能是0或1)进行归一化。因为我们知道这是一个1,我们骗了一点:我们通常不存储1在数字,因为它存储。因此,双精度浮点数通常具有53位精度,但实际上只存储 52位有效位数。



,不再是这样。这不是很难处理,但它仍然引入了一个特殊的情况 - 一个很少使用,所以CPU设计师(等)很少尝试优化它。因此,当对包含子字词的数据执行时,完全相同的代码可能会突然运行较慢


I was reading about the gradual underflow concept and how it is op important in the music industry Gradual overflow Application in Music

I well understand the problem of an overflow buffer, but this i don't know how to represent an underflow.

Can you please give me an example(a program preferably in c or c++) as in how a computer handles gradual underflow?

解决方案

Gradual underflow is related to what IEEE 754 calls "subnormal" numbers.

Consider using scientific notation in which you have (say) 10 digits of precision and exponents that can range from -99 through 99.

Under normal circumstances, you treat everything as scientific notation, so if you want to represent 1000, you represent it as 1e3 -- that is, 1 * 103.

Now, consider a number like 1.234e-102. The smallest exponent you can represent is -99. So, if you do your job the simplest possible way, you simply that since it has an exponent smaller than that, it's just 0. That would be "fast underflow".

In IEEE 754 (and related standards) you can store that as (essentially) 0.001234 * 10-99. In doing so, you may lose some precision compared to a normal number that has an exponent in the -99...99 range. On the other hand, you lose less than if you just rounded it to zero because it has an exponent smaller than -99. In fact, in this case it started with 4 significant digits, and as represented it retains all 4 significant digits.

On a computer, the numbers are represented in binary, so the numbers of significant digits and/or maximum range of exponents aren't round numbers when converted to decimal, but the same basic idea applies--when we have a number that's too small to represent in the normal format, we can still store it with the smallest exponent that can be represented, but also includes some leading zeros.

This does lead to one difficulty: numbers are normally stored in what's called normalized form. The "significand" part is normalized by shifting it left until the first digit is a 1 (keep in mind that since it's binary it can only be 0 or 1). Since we know it's a 1, we cheat a little: we don't normally store that 1 in the number as it's stored. So, a double precision floating point number normally has 53 bits of precision, but only actually stores 52 bits of significand.

With a subnormal number, that's no longer the case. That's not terribly difficult to deal with, but it still introduces a special case--and one that's only rarely used, so CPU designers (and such) rarely try to optimize for it. As a result, the exact same code can suddenly run a lot slower when executing on data that contains subnormals.

这篇关于逐渐下溢程序的表示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆