int的大小是否与所有语言相同,或者因您使用的语言而异? [英] Is the size of int is same for all languages or it varies with the language you use?

查看:85
本文介绍了int的大小是否与所有语言相同,或者因您使用的语言而异?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上我想问一下,数据类型的大小是否随着语言的变化而变化。



我尝试过的方法:



我无法找到这个?

Basically i wanna ask is this that size of datatype changes with language used or not.

What I have tried:

I am not able to find out this one?

推荐答案

Whooo!不。它不仅仅是语言,而是运行语言的环境。

例如,我见过使用16位int,32位int生成代码的C编译器,如果我还记得我已经看过128位整数了!



现代语言 - 或者至少是框架 - 定义一个int的大小,通常为32位这允许-2,147,483,648到2,147,483,647的大小范围,但如果它没有被语言明确定义那么它完全取决于实现。



所以不 。它不一样。
Whooo! Nope. It's not just the language, it's the environment in which the language will be run.
For example, I've seen C compilers that generate code using a 16 bit int, a 32 bit int, and if I recall correctly I've seen a 128 bit integer as well!

Modern languages - or at least frameworks - define a size for an int , normally at 32 bits as this allows for a good sized range of -2,147,483,648 to 2,147,483,647 but if it isn;t explicitly defined by the language then it is completely implementation dependant.

So "no". It's not the same.


谷歌是你的朋友......

整数(计算机科学) - 维基百科 [ ^ ]
Google is your friend...
Integer (computer science) - Wikipedia[^]


Quote:

int的大小是否相同对于所有语言或它是否因您使用的语言而异?

Is the size of int is same for all languages or it varies with the language you use?



int的大小随着时间而演变。

在80 s int是8位,因为'处理器是8位。

然后它是16位,现在通常是32位。

让我猜测它将来会是64位比特。

如果你得到一个70或80的C程序,int预计是8位。它随着时间的推移而改变。


Size of int have evolved with time.
In the 80"s int was 8 bits because' processors were 8 bits.
then it was 16 bits and now it is usually 32 bits.
lets guess in future it will be 64 bits.
if you get a C program from 70's or 80's, int are expected to be 8 bits. it have changed over time.


这篇关于int的大小是否与所有语言相同,或者因您使用的语言而异?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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