Why is float not a double on a 64-bit system? [closed]

匿名 (未验证) 提交于 2019-12-03 08:39:56

问题:

Considering an int will be 4 bytes on a 32-bit system and 8 bytes on a 64-bit system, why is float not treated the same? Why is size of a double != size of a float on a 64-bit system? Considering that the best native integer type is selected when I declare an int (which results in higher performance), shouldn't the same happen for float (which also results in a performance increase)?

Related question: Is it a bad idea to declare a type my_float (pardon the name!) that is float on 32-bit systems and double on 64-bit systems?

回答1:

Your question is based on a false premise. On most modern 64-bit systems, int is still 4 bytes. Why consume twice as much memory and twice as much memory bandwidth when such large integers are so rarely needed? On typical modern 64-bit systems, math on 64-bit integers is not faster than math on 32-bit integers, so there's no benefit to be had.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!