- 博客(5)
- 收藏
- 关注
原创 arithmetic overflow
今天在codility上做练习,发现了自己经常忽视的一个算数溢出的问题,mark一下。 int i = 2; int j = 2147483647; long long k = i + j; // arithmetic overflow! // should declare i or j as 'long long' too; otherwise, i+j is of type 'int'
2014-02-19 12:12:47
725
转载 STL中list的排序算法
转-注:因为非random access链表不适合做quick sort, 一直怀疑STL的list使用了merge sort. 今天在网上搜了一下,转至此处做个记录。 STL 中的List排序算法(in SGI STL) SGI STL笔记(list中的sort算法) template void list::sort() { if (node->next == node ||
2014-02-18 16:41:23
573
转载 signed和unsigned的比较
【转】signed和unsigned的比较 昨天,zrf师兄丢给我这样一个题,据说是微软面试题: unsigned int i=3; cout 问结果是多少。 第一反应:-3。不过结果似乎不是这样的,写了个程序,运行了一下,发现是:4294967293。很诡异的一个数字,怎么也想不明白为什么会是这么个奇怪的数字。但是在我发现这数的十六进制数是FFFFFFFD时,我想我已经离
2014-02-13 11:39:23
724
原创 using namespace ns_xxx不能用在class定义内部
class XXX { using namespace ns_xxx; // ERROR! }; using namespace ns_xxx; 竟然不能用在class定义里面,我直觉上一直以为没问题的。 用在namespace或function定义内部没问题。 具体原因可能与名字查找有关吧,没翻看标准,不纠结于语言细节了,赶紧干活吧!
2014-02-12 14:15:08
747
转载 What are the numbers that every computer engineer should know, according to Jeff Dean?
http://www.quora.com/What-are-the-numbers-that-every-computer-engineer-should-know-according-to-Jeff-Dean L1 cache reference: 0.5 nsBranch mispredict: 5 nsL2 cache reference: 7 nsMutex lock/unloc
2014-01-17 19:04:57
671
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人