1. <small id='8fTBd'></small><noframes id='8fTBd'>

    <legend id='8fTBd'><style id='8fTBd'><dir id='8fTBd'><q id='8fTBd'></q></dir></style></legend>

  2. <tfoot id='8fTBd'></tfoot>
    • <bdo id='8fTBd'></bdo><ul id='8fTBd'></ul>

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

      如何检查值是否为整数类型?

      How can I check if a value is of type Integer?(如何检查值是否为整数类型?)
      <i id='DM7yj'><tr id='DM7yj'><dt id='DM7yj'><q id='DM7yj'><span id='DM7yj'><b id='DM7yj'><form id='DM7yj'><ins id='DM7yj'></ins><ul id='DM7yj'></ul><sub id='DM7yj'></sub></form><legend id='DM7yj'></legend><bdo id='DM7yj'><pre id='DM7yj'><center id='DM7yj'></center></pre></bdo></b><th id='DM7yj'></th></span></q></dt></tr></i><div id='DM7yj'><tfoot id='DM7yj'></tfoot><dl id='DM7yj'><fieldset id='DM7yj'></fieldset></dl></div>

          <legend id='DM7yj'><style id='DM7yj'><dir id='DM7yj'><q id='DM7yj'></q></dir></style></legend>

          1. <tfoot id='DM7yj'></tfoot>

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

                <bdo id='DM7yj'></bdo><ul id='DM7yj'></ul>
                  <tbody id='DM7yj'></tbody>
              • 本文介绍了如何检查值是否为整数类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我需要检查一个值是否为整数.我发现了这个:如何检查输入值是否为整数还是浮点数?,但如果我没记错的话,即使 value 本身,变量仍然是 double 类型确实是一个整数.

                I need to check if a value is an integer. I found this: How to check whether input value is integer or float?, but if I'm not mistaken, the variable there is still of type double even though the value itself is indeed an integer.

                推荐答案

                如果输入值可以是整数以外的数字形式,请检查

                If input value can be in numeric form other than integer , check by

                if (x == (int)x)
                {
                   // Number is integer
                }
                

                如果正在传递字符串值,请使用 Integer.parseInt(string_var).请确保在转换失败时使用 try catch 进行错误处理.

                If string value is being passed , use Integer.parseInt(string_var). Please ensure error handling using try catch in case conversion fails.

                这篇关于如何检查值是否为整数类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                How can I detect integer overflow on 32 bits int?(如何检测 32 位 int 上的整数溢出?)
                Local variables before return statements, does it matter?(return 语句之前的局部变量,这有关系吗?)
                How to convert Integer to int?(如何将整数转换为整数?)
                How do I create an int array with randomly shuffled numbers in a given range(如何在给定范围内创建一个随机打乱数字的 int 数组)
                Inconsistent behavior on java#39;s ==(java的行为不一致==)
                Why is Java able to store 0xff000000 as an int?(为什么 Java 能够将 0xff000000 存储为 int?)

                    <tfoot id='Def4k'></tfoot>

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

                    <legend id='Def4k'><style id='Def4k'><dir id='Def4k'><q id='Def4k'></q></dir></style></legend>

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