久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<tfoot id='Ufxpi'></tfoot>
<legend id='Ufxpi'><style id='Ufxpi'><dir id='Ufxpi'><q id='Ufxpi'></q></dir></style></legend>
    <bdo id='Ufxpi'></bdo><ul id='Ufxpi'></ul>
    1. <i id='Ufxpi'><tr id='Ufxpi'><dt id='Ufxpi'><q id='Ufxpi'><span id='Ufxpi'><b id='Ufxpi'><form id='Ufxpi'><ins id='Ufxpi'></ins><ul id='Ufxpi'></ul><sub id='Ufxpi'></sub></form><legend id='Ufxpi'></legend><bdo id='Ufxpi'><pre id='Ufxpi'><center id='Ufxpi'></center></pre></bdo></b><th id='Ufxpi'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Ufxpi'><tfoot id='Ufxpi'></tfoot><dl id='Ufxpi'><fieldset id='Ufxpi'></fieldset></dl></div>

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

        負字符值 JAVA

        negative char Value JAVA(負字符值 JAVA)

          <bdo id='0HNyj'></bdo><ul id='0HNyj'></ul>

                • <tfoot id='0HNyj'></tfoot>
                    <tbody id='0HNyj'></tbody>
                  <legend id='0HNyj'><style id='0HNyj'><dir id='0HNyj'><q id='0HNyj'></q></dir></style></legend>

                  <small id='0HNyj'></small><noframes id='0HNyj'>

                  <i id='0HNyj'><tr id='0HNyj'><dt id='0HNyj'><q id='0HNyj'><span id='0HNyj'><b id='0HNyj'><form id='0HNyj'><ins id='0HNyj'></ins><ul id='0HNyj'></ul><sub id='0HNyj'></sub></form><legend id='0HNyj'></legend><bdo id='0HNyj'><pre id='0HNyj'><center id='0HNyj'></center></pre></bdo></b><th id='0HNyj'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='0HNyj'><tfoot id='0HNyj'></tfoot><dl id='0HNyj'><fieldset id='0HNyj'></fieldset></dl></div>
                  本文介紹了負字符值 JAVA的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  為什么會這樣:

                  char p = 0;
                  p--;
                  System.out.println(p);
                  

                  結果65535

                  為什么不給它一個編譯錯誤或運行時異常?我期望它,因為字符不能為負數.相反,它從倒掛開始倒數.提前致謝.

                  Why does not give it out a compilation error or a runtime Exception? I expected it as chars cannot be negative. Instead it starts back counting from upside down. Thanks in advance.

                  推薦答案

                  為什么不給它一個編譯錯誤或運行時異常?

                  Why does not give it out a compilation error or a runtime Exception?

                  因為語言規范要求原始類型的算術是模 2^width,所以 -1 變成 2^16-1 為一個 char.

                  Because the language specification mandates that arithmetic on primitive types is modulo 2^width, so -1 becomes 2^16-1 as a char.

                  在 整數運算部分,據說

                  內置的整數運算符不會以任何方式指示上溢或下溢.

                  The built-in integer operators do not indicate overflow or underflow in any way.

                  這樣就禁止拋出異常.

                  對于使用的后綴減量運算符,具體而言,其行為在 15.14.3

                  For the postfix-decrement operator used, specifically, its behaviour is specified in 15.14.3

                  否則,從變量的值中減去值 1,并將差值存儲回變量中.在減法之前,對值 1 和變量的值執行二進制數字提升(第 5.6.2 節).如有必要,通過縮小原始轉換(第 5.1.3 節)和/或在存儲變量之前對其類型進行裝箱轉換(第 5.1.7 節)來縮小差異.后綴遞減表達式的值是變量在新值被存儲之前的值.

                  Otherwise, the value 1 is subtracted from the value of the variable and the difference is stored back into the variable. Before the subtraction, binary numeric promotion (§5.6.2) is performed on the value 1 and the value of the variable. If necessary, the difference is narrowed by a narrowing primitive conversion (§5.1.3) and/or subjected to boxing conversion (§5.1.7) to the type of the variable before it is stored. The value of the postfix decrement expression is the value of the variable before the new value is stored.

                  二進制數字提升將值和 1 都轉換為 int(因為這里的類型是 char),因此您有中間結果 -1int,則進行窄化原語轉換:

                  The binary numeric promotion converts both, the value and 1, to int (since the type here is char), thus you have the intermediate result -1 as an int, then the narrowing primitive conversion is performed:

                  有符號整數到整數類型 T 的窄化轉換只會丟棄除 n 個最低位之外的所有位,其中 n 是用于表示類型 T 的位數.除了可能丟失有關數值,這可能會導致結果值的符號與輸入值的符號不同.

                  A narrowing conversion of a signed integer to an integral type T simply discards all but the n lowest order bits, where n is the number of bits used to represent type T. In addition to a possible loss of information about the magnitude of the numeric value, this may cause the sign of the resulting value to differ from the sign of the input value.

                  導致 0xFFFFchar 值(因為 Java 為其有符號整數類型指定二進制補碼表示,在 一元減號):

                  resulting in a char value of 0xFFFF (since Java specifies two's complement representation for its signed integer types, explicitly stated in the specification of unary minus):

                  對于整數值,取反與從零減法相同.Java 編程語言對整數使用二進制補碼表示,二進制補碼值的范圍不是對稱的,因此最大負 int 或 long 的取反會產生相同的最大負數.這種情況下會發生溢出,但不會拋出異常.對于所有整數值 x,-x 等于 (~x)+1.

                  For integer values, negation is the same as subtraction from zero. The Java programming language uses two's-complement representation for integers, and the range of two's-complement values is not symmetric, so negation of the maximum negative int or long results in that same maximum negative number. Overflow occurs in this case, but no exception is thrown. For all integer values x, -x equals (~x)+1.

                  對于超出范圍結果的一般環繞行為,例如 在乘法運算符的規范中:

                  For the general wrap-around behaviour for out-of-range results, as an example in the specification of the multiplication operator:

                  如果整數乘法溢出,則結果是數學乘積的低位,以某種足夠大的二進制補碼格式表示.因此,如果發生溢出,則結果的符號可能與兩個操作數的數學乘積的符號不同.

                  If an integer multiplication overflows, then the result is the low-order bits of the mathematical product as represented in some sufficiently large two's-complement format. As a result, if overflow occurs, then the sign of the result may not be the same as the sign of the mathematical product of the two operand values.

                  在整數加法的規范中出現類似的短語,需要減法來滿足a - b == a + (-b),所以溢出行為如下.

                  Similar phrases occur in the specification of integer addition, and subtraction is required to fulfill a - b == a + (-b), so the overflow behaviour follows.

                  這篇關于負字符值 JAVA的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  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?)
                      <bdo id='iJ81X'></bdo><ul id='iJ81X'></ul>
                    • <legend id='iJ81X'><style id='iJ81X'><dir id='iJ81X'><q id='iJ81X'></q></dir></style></legend>
                          <i id='iJ81X'><tr id='iJ81X'><dt id='iJ81X'><q id='iJ81X'><span id='iJ81X'><b id='iJ81X'><form id='iJ81X'><ins id='iJ81X'></ins><ul id='iJ81X'></ul><sub id='iJ81X'></sub></form><legend id='iJ81X'></legend><bdo id='iJ81X'><pre id='iJ81X'><center id='iJ81X'></center></pre></bdo></b><th id='iJ81X'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='iJ81X'><tfoot id='iJ81X'></tfoot><dl id='iJ81X'><fieldset id='iJ81X'></fieldset></dl></div>

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

                          <tfoot id='iJ81X'></tfoot>

                              <tbody id='iJ81X'></tbody>

                            主站蜘蛛池模板: 91免费在线 | 欧美一级毛片免费观看 | 久久久毛片 | 国产成人精品午夜视频免费 | 祝你幸福电影在线观看 | 99精品国产在热久久 | av在线免费观看网站 | 久久精品国产一区二区电影 | 午夜免费电影 | 成人福利网站 | 欧美日韩一区二区三区不卡视频 | 精品欧美乱码久久久久久 | 99视频免费看 | 色婷婷综合久久久中文字幕 | 天天摸天天看 | 国产探花在线观看视频 | 琪琪午夜伦伦电影福利片 | 国产精品女人久久久 | 狠狠色狠狠色综合系列 | 免费精品久久久久久中文字幕 | 一区二区三区亚洲 | 在线观看国产网站 | 二区在线视频 | 久久久久久亚洲精品不卡 | 亚洲视频在线看 | 国产精品成人一区二区三区吃奶 | 日本成人综合 | 亚洲福利在线观看 | 欧美精品一区二区三区蜜桃视频 | 日韩h | 亚洲日本视频 | 免费观看www7722午夜电影 | 日韩成人在线观看 | 亚州一区二区三区 | 亚洲精品国产电影 | 狠狠综合网 | 日韩av手机在线观看 | 日韩毛片免费视频 | 日韩av免费在线电影 | 在线观看成人 | 欧美精品一区二区三区在线播放 |