C中的整数类型未签名全部? [英] Integer type in C. Unsigned all?

查看:90
本文介绍了C中的整数类型未签名全部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否值得将我的C程序中的所有 int char 类型更改为 unsigned ,当我只使用物理数字时?



这个改变会让我的程序更快吗?

解决方案

不,它不会让你的程序更快。

CPU没有区分有符号整数和无符号整数 - 它们都被视为16,32或64位数字(取决于环境)以完全相同的方式。



如果你想加快编程速度,那么先把它计时到找出它最慢的地方,并将注意力集中在那里!慢代码通常是由于算法效率低而不是使用的整数类型引起的。 :笑:

Is it worth to change all the int and char types in my C program to unsigned, by the time I use only physical numbers?

Is this change will make my programm faster?

解决方案

No, it won't make your program any faster.
The CPU doesn't make any distinction between signed and unsigned integers - they are all treated as 16, 32, or 64 bit numbers (depending on environment) in exactly the same way.

If you want to speed you program up, then start by timing it to find out where it's slowest, and focus your attention on that! Slow code is more often caused because of inefficient algorithms, rather than type of integer used. :laugh:


这篇关于C中的整数类型未签名全部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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