任意precision号(GMP级) [英] Arbitrary precision numbers(GMP class)

查看:201
本文介绍了任意precision号(GMP级)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

非常大的浮点数是如何重新在内存psented $ P $?我可以想象,如果比如你想计算PI或欧拉恒说,200万的数字,你会分配一个字节数组庞大的数字的小数点的右侧。每个字节将存储2小数位的值与阵列将与数字和用于存储值中的字节数的数目的数据结构的一个成员。这究竟是怎么运作的?

How are extremely large floating point numbers represented in memory? I would imagine that if for instance you wanted to compute Pi or Euler's constant to say, 2,000,000 digits that you would allocate a massive array of bytes for the digits to the right of the decimal place. Each byte would store 2 decimal place values and the array would be a member of a data structure with the number of digits and number of bytes used to store the value. Is this how it works?

推荐答案

目前的计算机有32位或64位的寄存器,这样做对字节计算是非常低效的。此外,计算机二进制工作,所以使用碱是一个功率的2是更有效的。像Mysticial表示,他们会使用基地2 32 或2 64 。每个计算机字将存储的数量的数字和它们的工作位逐位

Current computers have 32 or 64-bit registers, so doing calculations on bytes is very inefficient. Also, computers work in binary, so using a base that is a power of 2 is more efficient. They'll use base 232 or 264 like Mysticial said. Each computer word will store a digit of the number and they work digit-by-digit.

在某些情况下,你并不需要太多的计算,但大部分你输入和输出,而不是小数字符的时间。这种情况下,使用碱是一个功率或10是更有效。您可以使用基地10 9 在32位计算机和10 19 64位的人,因为这是你可以在32位或64位存储10最大功率值

In some cases you don't need much calculations but most of the time you're inputting and outputting decimal characters instead. This case using a base that is a power or 10 is more efficient. You can use base 109 in 32-bit computers and 1019 in 64-bit ones because that's the largest power of 10 you can store in a 32 or 64-bit value

这篇关于任意precision号(GMP级)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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