GithubHelp home page GithubHelp logo

Comments (3)

rqycpp avatar rqycpp commented on May 19, 2024

没有问题,只是两种写法而已。相比之下我觉得叶老师的写法更简洁一些(即不需要特殊处理)。
以码点U+FFFF为例:

  1. U+FFFF(码点位数16)的二进位为1111 111111 111111
  2. u>>12 = 1111(二进位)
  3. (u>>12) & 0xFF == &(u>>12) & 0xF

也就是说,你所关注的那些不经该进行&运算的位实际上是0,而0&1 == 0,对结果无影响。
00001111 & 11111111 == 00001111
1111 & 1111 == 1111

补充一点:你的第一条注释中0x2F == 101111,事实上0x1F == 11111。

from json-tutorial.

miloyip avatar miloyip commented on May 19, 2024

第一个字节其实不写 & 也可以的,只是一些编译器会错误地 warn 有机会溢出。

from json-tutorial.

Alex1990 avatar Alex1990 commented on May 19, 2024

感谢 @rqy1994 @miloyip 解答和指正,有点儿理解了。

from json-tutorial.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.