![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
c语言
那就叫我兔子吧
这个作者很懒,什么都没留下…
展开
-
利用位运算来判断两个数是否异号可能会出现的问题
通常情况下判断两个数是否异号最直接的方法是bool cmp(int a, int b){ return a*b<0;}这种方法其实存在一个潜在问题,如果a*b的值超过了int类型的最大值,就会越界出错,而且是非常有可能发生的一件事为了减少这个问题发生的可能,要把接收数字的容器换为long long。有没有能从根本上解决这个问题的方法呢?我在网上找到了一种利用位运算的方法方法来源贴点这里即bool cmp(int a, int b){ return (a^b)<0}这原创 2021-02-13 17:34:14 · 824 阅读 · 1 评论 -
关于c语言中%g(G)的用法和精度问题
c初学者关于%g(G)及其精度需要知道的一些事格式说明符号g(G)在c标准中的说明是g double Signed value printed in f or e format, whichever is more compact for the given value and precision. The e format is used only when the exponent of the value is less than –bai4 or greater than or equal to原创 2020-09-14 14:04:50 · 11488 阅读 · 6 评论