pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

<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="j7x57zx" id='Ufxpi'><tfoot id='Ufxpi'></tfoot><dl id='Ufxpi'><fieldset id='Ufxpi'></fieldset></dl></div>

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

        負(fù)字符值 JAVA

        negative char Value JAVA(負(fù)字符值 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="vxb75h7" id='0HNyj'><tfoot id='0HNyj'></tfoot><dl id='0HNyj'><fieldset id='0HNyj'></fieldset></dl></div>
                  本文介紹了負(fù)字符值 JAVA的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問(wèn)題描述

                  為什么會(huì)這樣:

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

                  結(jié)果65535

                  為什么不給它一個(gè)編譯錯(cuò)誤或運(yùn)行時(shí)異常?我期望它,因?yàn)樽址荒転樨?fù)數(shù).相反,它從倒掛開(kāi)始倒數(shù).提前致謝.

                  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.

                  推薦答案

                  為什么不給它一個(gè)編譯錯(cuò)誤或運(yùn)行時(shí)異常?

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

                  因?yàn)檎Z(yǔ)言規(guī)范要求原始類型的算術(shù)是模 2^width,所以 -1 變成 2^16-1 為一個(gè) char.

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

                  在 整數(shù)運(yùn)算部分,據(jù)說(shuō)

                  內(nèi)置的整數(shù)運(yùn)算符不會(huì)以任何方式指示上溢或下溢.

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

                  這樣就禁止拋出異常.

                  對(duì)于使用的后綴減量運(yùn)算符,具體而言,其行為在 15.14.3

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

                  否則,從變量的值中減去值 1,并將差值存儲(chǔ)回變量中.在減法之前,對(duì)值 1 和變量的值執(zhí)行二進(jìn)制數(shù)字提升(第 5.6.2 節(jié)).如有必要,通過(guò)縮小原始轉(zhuǎn)換(第 5.1.3 節(jié))和/或在存儲(chǔ)變量之前對(duì)其類型進(jìn)行裝箱轉(zhuǎn)換(第 5.1.7 節(jié))來(lái)縮小差異.后綴遞減表達(dá)式的值是變量在新值被存儲(chǔ)之前的值.

                  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.

                  二進(jìn)制數(shù)字提升將值和 1 都轉(zhuǎn)換為 int(因?yàn)檫@里的類型是 char),因此您有中間結(jié)果 -1int,則進(jìn)行窄化原語(yǔ)轉(zhuǎn)換:

                  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:

                  有符號(hào)整數(shù)到整數(shù)類型 T 的窄化轉(zhuǎn)換只會(huì)丟棄除 n 個(gè)最低位之外的所有位,其中 n 是用于表示類型 T 的位數(shù).除了可能丟失有關(guān)數(shù)值,這可能會(huì)導(dǎo)致結(jié)果值的符號(hào)與輸入值的符號(hào)不同.

                  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.

                  導(dǎo)致 0xFFFFchar 值(因?yàn)?Java 為其有符號(hào)整數(shù)類型指定二進(jìn)制補(bǔ)碼表示,在 一元減號(hào)):

                  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):

                  對(duì)于整數(shù)值,取反與從零減法相同.Java 編程語(yǔ)言對(duì)整數(shù)使用二進(jìn)制補(bǔ)碼表示,二進(jìn)制補(bǔ)碼值的范圍不是對(duì)稱的,因此最大負(fù) int 或 long 的取反會(huì)產(chǎn)生相同的最大負(fù)數(shù).這種情況下會(huì)發(fā)生溢出,但不會(huì)拋出異常.對(duì)于所有整數(shù)值 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.

                  對(duì)于超出范圍結(jié)果的一般環(huán)繞行為,例如 在乘法運(yùn)算符的規(guī)范中:

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

                  如果整數(shù)乘法溢出,則結(jié)果是數(shù)學(xué)乘積的低位,以某種足夠大的二進(jìn)制補(bǔ)碼格式表示.因此,如果發(fā)生溢出,則結(jié)果的符號(hào)可能與兩個(gè)操作數(shù)的數(shù)學(xué)乘積的符號(hào)不同.

                  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.

                  在整數(shù)加法的規(guī)范中出現(xiàn)類似的短語(yǔ),需要減法來(lái)滿足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.

                  這篇關(guān)于負(fù)字符值 JAVA的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  How can I detect integer overflow on 32 bits int?(如何檢測(cè) 32 位 int 上的整數(shù)溢出?)
                  Local variables before return statements, does it matter?(return 語(yǔ)句之前的局部變量,這有關(guān)系嗎?)
                  How to convert Integer to int?(如何將整數(shù)轉(zhuǎn)換為整數(shù)?)
                  How do I create an int array with randomly shuffled numbers in a given range(如何在給定范圍內(nèi)創(chuàng)建一個(gè)隨機(jī)打亂數(shù)字的 int 數(shù)組)
                  Inconsistent behavior on java#39;s ==(java的行為不一致==)
                  Why is Java able to store 0xff000000 as an int?(為什么 Java 能夠?qū)?0xff000000 存儲(chǔ)為 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="pz5ljrh" 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>

                            主站蜘蛛池模板: 单螺旋速冻机-双螺旋-流态化-隧道式-食品速冻机厂家-广州冰泉制冷 | 选矿设备-新型重选设备-金属矿尾矿重选-青州冠诚重工机械有限公司 | 深圳3D打印服务-3D打印加工-手板模型加工厂-悟空打印坊 | 检验科改造施工_DSA手术室净化_导管室装修_成都特殊科室建设厂家_医疗净化工程公司_四川华锐 | 西门子代理商_西门子变频器总代理-翰粤百科| 北京公寓出租网-北京酒店式公寓出租平台 | 东莞画册设计_logo/vi设计_品牌包装设计 - 华略品牌设计公司 | 桨叶搅拌机_螺旋挤压/方盒旋切造粒机厂家-无锡市鸿诚输送机械有限公司 | 东莞动力锂电池保护板_BMS智能软件保护板_锂电池主动均衡保护板-东莞市倡芯电子科技有限公司 | 电镀标牌_电铸标牌_金属标贴_不锈钢标牌厂家_深圳市宝利丰精密科技有限公司 | 双吸泵,双吸泵厂家,OS双吸泵-山东博二泵业有限公司 | 减速机电机一体机_带电机减速器一套_德国BOSERL电动机与减速箱生产厂家 | 杭州月嫂技术培训服务公司-催乳师培训中心报名费用-产后康复师培训机构-杭州优贝姆健康管理有限公司 | 扬尘在线监测系统_工地噪声扬尘检测仪_扬尘监测系统_贝塔射线扬尘监测设备「风途物联网科技」 | 成人纸尿裤,成人尿不湿,成人护理垫-山东康舜日用品有限公司 | 罗氏牛血清白蛋白,罗氏己糖激酶-上海嵘崴达实业有限公司 | 铁艺,仿竹,竹节,护栏,围栏,篱笆,栅栏,栏杆,护栏网,网围栏,厂家 - 河北稳重金属丝网制品有限公司 山东太阳能路灯厂家-庭院灯生产厂家-济南晟启灯饰有限公司 | 消泡剂-水处理消泡剂-涂料消泡剂-切削液消泡剂价格-东莞德丰消泡剂厂家 | 团建-拓展-拓展培训-拓展训练-户外拓展训练基地[无锡劲途] | 冷藏车厂家|冷藏车价格|小型冷藏车|散装饲料车厂家|程力专用汽车股份有限公司销售十二分公司 | 生产自动包装秤_颗粒包装秤_肥料包装秤等包装机械-郑州鑫晟重工科技有限公司 | 防火板_饰面耐火板价格、厂家_品牌认准格林雅 | 「银杏树」银杏树行情价格_银杏树种植_山东程锦园林 | 雷冲击高压发生器-水内冷直流高压发生器-串联谐振分压器-武汉特高压电力科技有限公司 | 西门子气候补偿器,锅炉气候补偿器-陕西沃信机电工程有限公司 | 定制/定做冲锋衣厂家/公司-订做/订制冲锋衣价格/费用-北京圣达信 | 京马网,京马建站,网站定制,营销型网站建设,东莞建站,东莞网站建设-首页-京马网 | 闭端端子|弹簧螺式接线头|防水接线头|插线式接线头|端子台|电源线扣+护线套|印刷电路板型端子台|金笔电子代理商-上海拓胜电气有限公司 | 合肥礼品公司-合肥礼品定制-商务礼品定制公司-安徽柏榽商贸有限公司 | 杭州代理记账多少钱-注册公司代办-公司注销流程及费用-杭州福道财务管理咨询有限公司 | 即用型透析袋,透析袋夹子,药敏纸片,L型涂布棒-上海桥星贸易有限公司 | 首页 - 军军小站|张军博客 | 家庭教育吧-在线家庭教育平台,专注青少年家庭教育 | [品牌官网]贵州遵义双宁口腔连锁_贵州遵义牙科医院哪家好_种植牙_牙齿矫正_原华美口腔 | 数年网路-免费在线工具您的在线工具箱-shuyear.com | 临时厕所租赁_玻璃钢厕所租赁_蹲式|坐式厕所出租-北京慧海通 | 智能交通网_智能交通系统_ITS_交通监控_卫星导航_智能交通行业 | 一体化净水器_一体化净水设备_一体化水处理设备-江苏旭浩鑫环保科技有限公司 | 电磁铁_推拉电磁铁_机械手电磁吸盘电磁铁厂家-广州思德隆电子公司 | 视觉检测设备_自动化检测设备_CCD视觉检测机_外观缺陷检测-瑞智光电 | 钢托盘,铁托盘,钢制托盘,镀锌托盘,饲料托盘,钢托盘制造商-南京飞天金属13260753852 |