1. <legend id='hbjan'><style id='hbjan'><dir id='hbjan'><q id='hbjan'></q></dir></style></legend>

          <bdo id='hbjan'></bdo><ul id='hbjan'></ul>
      1. <i id='hbjan'><tr id='hbjan'><dt id='hbjan'><q id='hbjan'><span id='hbjan'><b id='hbjan'><form id='hbjan'><ins id='hbjan'></ins><ul id='hbjan'></ul><sub id='hbjan'></sub></form><legend id='hbjan'></legend><bdo id='hbjan'><pre id='hbjan'><center id='hbjan'></center></pre></bdo></b><th id='hbjan'></th></span></q></dt></tr></i><div id='hbjan'><tfoot id='hbjan'></tfoot><dl id='hbjan'><fieldset id='hbjan'></fieldset></dl></div>
      2. <small id='hbjan'></small><noframes id='hbjan'>

      3. <tfoot id='hbjan'></tfoot>

        检查 int 是否在两个数字之间

        时间:2023-10-01

          <small id='LBIB3'></small><noframes id='LBIB3'>

            <tbody id='LBIB3'></tbody>
        1. <tfoot id='LBIB3'></tfoot>
            <bdo id='LBIB3'></bdo><ul id='LBIB3'></ul>

              <i id='LBIB3'><tr id='LBIB3'><dt id='LBIB3'><q id='LBIB3'><span id='LBIB3'><b id='LBIB3'><form id='LBIB3'><ins id='LBIB3'></ins><ul id='LBIB3'></ul><sub id='LBIB3'></sub></form><legend id='LBIB3'></legend><bdo id='LBIB3'><pre id='LBIB3'><center id='LBIB3'></center></pre></bdo></b><th id='LBIB3'></th></span></q></dt></tr></i><div id='LBIB3'><tfoot id='LBIB3'></tfoot><dl id='LBIB3'><fieldset id='LBIB3'></fieldset></dl></div>

              <legend id='LBIB3'><style id='LBIB3'><dir id='LBIB3'><q id='LBIB3'></q></dir></style></legend>
                • 本文介绍了检查 int 是否在两个数字之间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  如果你试图找出一个 int 是否介于两个数字之间,为什么不能这样做:

                  Why can't do you this if you try to find out whether an int is between to numbers:

                  if(10 < x < 20)
                  

                  你必须这样做

                  if(10<x && x<20)
                  

                  这似乎有点开销.

                  推荐答案

                  一个问题是三元关系构造会引入严重的解析器问题:

                  One problem is that a ternary relational construct would introduce serious parser problems:

                  <expr> ::= <expr> <rel-op> <expr> |
                             ... |
                             <expr> <rel-op> <expr> <rel-op> <expr>
                  

                  当您尝试使用典型的 PGS 来表达这些产生式的语法时,您会发现在第一个 <rel-op> 处存在移位归约冲突.解析器需要先查看任意数量的符号,以查看是否存在第二个 <rel-op>,然后才能确定使用的是二进制还是三元形式.在这种情况下,您不能简单地忽略冲突,因为这会导致解析不正确.

                  When you try to express a grammar with those productions using a typical PGS, you'll find that there is a shift-reduce conflict at the point of the first <rel-op>. The parse needs to lookahead an arbitrary number of symbols to see if there is a second <rel-op> before it can decide whether the binary or ternary form has been used. In this case, you could not simply ignore the conflict because that would result in incorrect parses.

                  我并不是说这个语法是致命的模棱两可.但我认为你需要一个回溯解析器来正确处理它.对于以快速编译为主要卖点的编程语言来说,这是一个严重的问题.

                  I'm not saying that this grammar is fatally ambiguous. But I think you'd need a backtracking parser to deal with it correctly. And that is a serious problem for a programming language where fast compilation is a major selling point.

                  这篇关于检查 int 是否在两个数字之间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:四舍五入将其转换为 int (java) 下一篇:!= 和 == 运算符如何处理 Java 中的整数?

                  相关文章

                  最新文章

                  1. <small id='kgqfx'></small><noframes id='kgqfx'>

                    1. <i id='kgqfx'><tr id='kgqfx'><dt id='kgqfx'><q id='kgqfx'><span id='kgqfx'><b id='kgqfx'><form id='kgqfx'><ins id='kgqfx'></ins><ul id='kgqfx'></ul><sub id='kgqfx'></sub></form><legend id='kgqfx'></legend><bdo id='kgqfx'><pre id='kgqfx'><center id='kgqfx'></center></pre></bdo></b><th id='kgqfx'></th></span></q></dt></tr></i><div id='kgqfx'><tfoot id='kgqfx'></tfoot><dl id='kgqfx'><fieldset id='kgqfx'></fieldset></dl></div>
                      <tfoot id='kgqfx'></tfoot>

                    2. <legend id='kgqfx'><style id='kgqfx'><dir id='kgqfx'><q id='kgqfx'></q></dir></style></legend>
                      • <bdo id='kgqfx'></bdo><ul id='kgqfx'></ul>