okey3m 发表于 2012-2-17 23:05

请教一个软件保存用户选项的问题

最近在看 totalcommander 的帮助文件的时候, 发现 ini 里面有个选项的设置是这样的

DirTabOptions=824
Sum of the following options:
1: Tabs always visible
2: Tabs on multiple lines
4: All tabs have the same width
8: Tab text length limit enabled (see DirTabLimit)
16: Confirm "Close all tabs"
32: Close tabs with a double click
64: Open new tabs in the foreground
128: Open new tabs near the current tab
256: Show an asterisk * for locked tabs
512: Activate target panel when clicking on one of its tabs
1024: Show drive letter of current drive in the tab title
觉得这种用数字相加来识别叠加选项的方式好时髦, 请教一下这是什么原理? 有相关的简介文章可以看一下么, 求关键字...

zs1109 发表于 2012-2-17 23:16

0x1
0x2
0x4
0x8
0x10
0x20
....

00000000001
00000000010
00000000100
00000001000
...
10000000000

okey3m 发表于 2012-2-17 23:45

谢谢 ls, 原来是二进制... 那么请问一下这种存储方式有叫什么名称么? 想学习一下...

trentswd 发表于 2012-2-17 23:56

不时髦,位运算,死程经常用
常用的运算符有按位与、按位惑、按位异或、按位取非之类的,反正不少函数的参数flag就是用按位或的方式叠加的

real_zyf 发表于 2012-2-18 00:01

俗称标志位

okey3m 发表于 2012-2-18 00:16

非常感谢 ls 两位, 搜了一下, 大致了解原理啦!
页: [1]
查看完整版本: 请教一个软件保存用户选项的问题