计算分数的精确值

所属分类:数据结构
开发工具:C/C++
文件大小:1KB
下载次数:60
上传日期:2005-12-05 15:08:21
上 传 者沧海遗梦
说明:  使用数组精确计算M/N(0<M<N<=100)的值。如果M/N是无限循环小数,则计算并输出它的第一循环节,同时要求输出 循环节的起止位置(小数位的序号) *问题分析与算法设计 由于计算机字长的限制,常规的浮点运算都有精度限制,为了得到高精度的计算结果,就必须自行设计实现方法。 为了实现高精度的计算,可将商存放在一维数组中,数组的每个元素存放一位十进制数,即商的第一位存放在第一个元素中,商的第二位存放在第二个元素中....,依次类推。这样就可以使用数组不表示一个高精度的计算结果。 进行除法运算时可以模拟人的手工操作,即每次求出商的第一位后,将余数乘以10,再计算商的下一位,重复以上过程,当某次计算后的余数为0 时,表示M/N为有限不循环小数某次计算后的余数与前面的某个余数相同时,则M/N为无限循环小数,从该余数第一次出现之后所求得的各位数就是小数的循环节。 程序具体实现时,采用了数组和其它一些技巧来保存除法运算所得到的余数和商的各位数。
(arrays precise calculation of the M/N (0lt; Mlt; Nlt; = 100) value. If M/N is unlimited circulator, calculated and exporting its first cycle of festivals, while output cycle requirements of section starting and ending location (number of decimal places)* Analysis and design of computer algorithms size limitations, conventional precision floating-point operations have restrictions, in order to have a high-precision the results, we must design their own method. In order to achieve high precision calculations can be stored in a business-dimensional arrays, each array element placed a decimal number, the first one in a storage element, the second in the second storage element ..., followed by analogy. This array can use it does not mean that a highly accurate results. For computing divisi)

文件列表:
计算分数的精确值.txt (2183, 2005-12-05)

近期下载者

相关文件


收藏者