位運算符2

class TestExer1{public static void main(String[] args){int m = 12;int n = 5;System.out.println("m:" + m + " n:" + n);//方法一:提供一個臨時變量。//int temp = m;//       m = n;//       n = temp;//System.out.println("m:" + m + " n:" + n);//方法二:當m和n較大時,有可能出現精度損失//m = m + n;//m = 12 + 5;//n = m - n;//n = 17 - 5;//m = m - n;//m = 17- 12//System.out.println("m:" + m + " n:" + n);//方法三:優點:沒有上面兩種方法的缺點。 缺點:難!m = m ^ n;n = m ^ n;//(m ^ n) ^ n == mm = m ^ n;//(m ^ n) ^ m == nSystem.out.println("m:" + m + " n:" + n);//問題://60  手動的方式,從控制臺輸出60的十六進制。int i = 61;//自動調用Integer類現成的方法String binary = Integer.toBinaryString(i);System.out.println(binary);String hex = Integer.toHexString(i);//轉為16進制
        System.out.println(hex);/*char c = 'a';char c1 = (char)(c + 2);System.out.println(c1);//c*/int j = i & 15;//獲取到i的最低4位對應的值。//13String k1 = (j <= 9)? j + "" : (char)(j - 10 + 'a') + "";//d //System.out.println(k1);
i = i >> 4;//3int z = i & 15;//3String k2 = (z <= 9)? z + "" : (char)(z - 10 + 'a') + "";//3System.out.println(k2 + k1);//3+d
    }
}

輸出結果:

m:12 n:5
m:5 n:12
111101
3d
3d

轉載于:https://www.cnblogs.com/wangmengge/p/8630479.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/280864.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/280864.shtml
英文地址,請注明出處:http://en.pswp.cn/news/280864.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

C# 實例解析事件委托之EventHandler

概述事件屬于委托的一個子集&#xff0c;像我們平時界面上的鼠標點擊按鈕后響應事件、事件的發布和訂閱等都需要用到委托.通過委托可以很好的實現類之間的解耦好。事件委托EventHandler的函數原型如下&#xff1a;delegate 表示這個個委托&#xff0c;事件委托沒有返回值&#…

C# HttpWebRequest post 數據與上傳圖片到server

主體 Dictionary<string, object> postData new Dictionary<string, object>(); string fileFullPath this.imgFullPath;if (!File.Exists(fileFullPath)){Message(Error, "file not exist: " fileFullPath);goto EndGetPost;}// 先定義一個…

多虧了Google相冊,如何一鍵釋放Android手機上的空間

Let’s be real here: modern smartphones have limited storage. While they’re coming with a lot more than they used to, it’s easy to fill 32GB without even realizing it. And with today’s high-end cameras, well, pictures and videos can quickly consume a bi…

用window.location.href實現頁面跳轉

在寫ASP.Net程序的時候&#xff0c;我們經常遇到跳轉頁面的問題&#xff0c;我們經常使用Response.Redirect &#xff0c;如果客戶要在跳轉的時候使用提示&#xff0c;這個就不靈光了&#xff0c;如&#xff1a;Response.Write("<script>alert(恭喜您&#xff0c;注…

(一)使用appium之前為什么要安裝nodejs???

很多人在剛接觸appium自動化時&#xff0c;可能會像我一樣&#xff0c;按照教程搭建好環境后&#xff0c;卻不知道使用appium之前為什么要用到node.js&#xff0c;nodejs到底和appium是什么關系&#xff0c;對nodejs也不是很了解&#xff0c;接下來我和大家一起理解一下他們之間…

WPF效果第二百零四篇之自定義更新控件

好久沒有更新文章,今天抽空來分享一下最近玩耍的自定義控件;里面包含了自定義控件、依賴屬性和路由事件;來看看最終實現的效果:1、先來看看前臺Xaml布局和綁定:<Style TargetType"{x:Type Cores:UploadWithProgressControl}"><Setter Property"Templat…

u3d 逐個點運動,路徑運動。 U3d one by one, path motion.

u3d 逐個點運動&#xff0c;路徑運動。 U3d one by one, path motion. 作者&#xff1a;韓夢飛沙 Author&#xff1a;han_meng_fei_sha 郵箱&#xff1a;313134555qq.com E-mail: 313134555 qq.com 逐個點運動&#xff0c;路徑運動。 Im going to do some motion and path. 如果…

小米凈水器底部漏水_漏水傳感器:您可能沒有的最容易被忽視的智能家居設備...

小米凈水器底部漏水While most smarthome products are aimed at convenience, there’s one smarthome device that’s actually quite useful, possibly saving you headaches and ton of money: the trusty water leak sensor. 雖然大多數智能家居產品都旨在提供便利&#x…

Unity3D筆記十 游戲元素

一、地形 1.1 樹元素 1.2 草元素 二、光源 2.1 點光源 點光源&#xff08;Point Light&#xff09;&#xff1a;好像包圍在一個類似球形的物體中&#xff0c;讀者可將球形理解為點光源的照射范圍&#xff0c;就像家里的燈泡可以照亮整個屋子一樣。創建點光源的方式為在Hierarch…

BZOJ3511: 土地劃分

【傳送門&#xff1a;BZOJ3511】 簡要題意&#xff1a; 給出n個點&#xff0c;m條邊&#xff0c;每個點有A和B兩種形態&#xff0c;一開始1為A&#xff0c;n為B 給出VA[i]和VB[i]&#xff0c;表示第i個點選擇A和B形態的價值 每條邊給出x,y,EA,EB,EC&#xff0c;表示如果x和y都為…

facebook 文本分類_如何禁用和自定義Facebook的通知,文本和電子郵件

facebook 文本分類Facebook is really keen on keeping you on their platform. One of the ways they do that is by sending you notifications whenever the tiniest thing happens. And you won’t just see them on the site—Facebook will also notify you by email, wi…

django06: ORM示例2--uer 與file

存放路徑&#xff1a;https://git.lug.ustc.edu.cn/ 筆記 外鍵與多鍵 path models.ForeignKey(to"Path")file models.ManyToManyField(to"File") code 處理方式 new_path request.POST.get("new_path",None)models.File.objects.create(…

Error opening terminal: xterm-256color

在使用gdb調試linux內核時&#xff0c;提示如下錯誤&#xff1a; arm-none-linux-gnueabi-gdb --tui vmlinux Error opening terminal: xterm-256color. 解決辦法&#xff1a; 1、 edit your .bash_profile file vim .bash_profile 2、commnet #export TERMxterm-256colo…

四種簡單的排序算法

四種簡單的排序算法 我覺得如果想成為一名優秀的開發者&#xff0c;不僅要積極學習時下流行的新技術&#xff0c;比如WCF、Asp.Net MVC、AJAX等&#xff0c;熟練應用一些已經比較成熟的技術&#xff0c;比如Asp.Net、WinForm。還應該有著牢固的計算機基礎知識&#xff0c;比如數…

Xampp修改默認端口號

為什么80%的碼農都做不了架構師&#xff1f;>>> Xampp默認的端口使用如下&#xff1a; Httpd使用80端口 Httpd_ssl使用443端口 Mysql使用3306端口 ftp使用21端口 但是&#xff0c;在如上端口被占用的情況下&#xff0c;我們可以通過修改xampp默認端口的方法&…

為什么csrss進程有三個_什么是客戶端服務器運行時進程(csrss.exe),為什么在我的PC上運行它?...

為什么csrss進程有三個If you have a Windows PC, open your Task Manager and you’ll definitely see one or more Client Server Runtime Process (csrss.exe) processes running on your PC. This process is an essential part of Windows. 如果您使用的是Windows PC&…

使用c#的 async/await編寫 長時間運行的基于代碼的工作流的 持久任務框架

持久任務框架 &#xff08;DTF&#xff09; 是基于async/await 工作流執行框架。工作流的解決方案很多&#xff0c;包括Windows Workflow Foundation&#xff0c;BizTalk&#xff0c;Logic Apps, Workflow-Core 和 Elsa-Core。最近我在Dapr 的倉庫里跟蹤工作流構建塊的進展時&a…

bat批處理筆記

變量 1.CMD窗口變量&#xff0c;變量名必須用單%引用&#xff08;即&#xff1a;%variable&#xff09; 外部變量&#xff0c;是系統制定的&#xff0c;只有9個&#xff0c;專門保存外部參數的&#xff0c;就是運行批處理時加的參數。只有 %1 %2 %3 %4 ...... %9。 在bat內直…

多目標跟蹤(MOT)論文隨筆-SIMPLE ONLINE AND REALTIME TRACKING (SORT)

轉載請標明鏈接&#xff1a;http://www.cnblogs.com/yanwei-li/p/8643336.html 網上已有很多關于MOT的文章&#xff0c;此系列僅為個人閱讀隨筆&#xff0c;便于初學者的共同成長。若希望詳細了解&#xff0c;建議閱讀原文。 本文是使用 tracking by detection 方法進行多目標…

明日大盤走勢分析

如上周所述&#xff0c;大盤在4與9號雙線壓力下&#xff0c;上攻乏力。今天小幅下跌0.11%&#xff0c;漲511&#xff0c;平76&#xff0c;跌362&#xff0c;說明個股還是比較活躍&#xff0c;而且大盤上漲趨勢未加改變&#xff0c;只是目前攻堅&#xff0c;有點缺乏外部的助力。…