浮点数如何存储在内存中 [英] how does floating point numbers get stored in memory
本文介绍了浮点数如何存储在内存中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
由于计算机只能理解其下的0和1,因此如何在内存中将12.1234之类的浮点数表示为一组0和1,
as computer understands only 0's and 1's underneath,how does floating point numbers like 12.1234 gets represented in memory as a set of 0's and 1's ,
是否通过各自的ASCII值1、2,...来存储它. ,1,2,3,4 ..?
does it gets stored by respective ASCII values of 1 ,2, . ,1,2,3,4 respectively..?
推荐答案
据我所知,浮点数(用于单精度)按如下方式存储在内存中:
As far as I know flaoting numbers(for single precision) are stored in memory as follows:
- 符号s(表示它是正数还是负数)-1位
- 尾数m(基本上是您的数字-24位
- 指数e-8位
例如:
3.14159
表示如下:
0 10000100 11001001000011111100111
^ ^ ^
| | |
| | +--- significand = 0.7853975
| |
| +------------------- exponent = 4
|
+------------------------- sign = 0 (positive)
请注意,.
根本没有存储在内存中.
Do note that .
is not stored at all in memory.
作为良好参考,请阅读每个计算机科学家应了解的知识浮点算法和浮点
As a good reference read What Every Computer Scientist Should Know About Floating-Point Arithmetic and Floating Point
这篇关于浮点数如何存储在内存中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文