计算机中的「魔数」(magic number)

摘自wikipedia:https://en.wikipedia.org/wiki/Magic_number_%28programming%29#Examples

In computer programming, the term magic number has multiple meanings. It could refer to one or more of the following:

  • A constant numerical or text value used to identify a file format or protocol; for files, see List of file signatures
  • Distinctive unique values that are unlikely to be mistaken for other meanings (e.g., Globally Unique Identifiers)
  • Unique values with unexplained meaning or multiple occurrences which could (preferably) be replaced with named constants

例如BMP图片文件的前缀是“BM”,JPEG图片文件的前缀是“JFIF”,这些文件的前缀就算是Magic number,这是指上面的第一种情况。再如Linux系统使用的uImage压缩内核的前缀是:0x27051956,这个就是uImage的Magic number,属于上面说的后面两种情况。三种情况都有共同点,都是用来作为区别事物的,一般用于程序检测文件类型做对应的处理工作。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值