Java BigInteger類| toByteArray()方法與示例

BigInteger類testBit()方法 (BigInteger Class testBit() method)

  • testBit() method is available in java.math package.

    testBit()方法在java.math包中可用。

  • testBit() method is used to convert this BigInteger to a byte [] that holds 2's complement denotation of this BigInteger and the array capacity is enough to represent this BigInteger with one extra bit for the sign.

    testBit()方法用于將該BigInteger轉換為一個字節[],該字節持有此BigInteger的2的補碼表示,并且數組容量足以用一個額外的符號表示此BigInteger。

  • testBit() method is a non-static method, it is accessible with the class object only and if we try to access the method with the class name then we will get an error.

    testBit()方法是一個非靜態方法,只能通過類對象訪問,如果嘗試使用類名稱訪問該方法,則會收到錯誤消息。

  • testBit() method does not throw an exception at the time of converting this object to a byte array.

    在將此對象轉換為字節數組時, testBit()方法不會引發異常。

Syntax:

句法:

    public byte[] toByteArray();

Parameter(s):

參數:

  • None

    沒有

Return value:

返回值:

The return type of this method is byte[], it represents this BigInteger in terms of 2’s complement in byte array.

此方法的返回類型為byte [] ,它以字節數組中2的補碼形式表示此BigInteger。

Example:

例:

// Java program to demonstrate the example 
// of byte[] toByteArray() method of BigInteger
import java.math.*;
import java.util.*;
public class ToByteArrayOfBI {
public static void main(String args[]) {
// Initializes a variable str
String str = "145";
// Initializes a BigInteger object  
BigInteger b_int = new BigInteger(str);
// returns the convert this BigInteger 
// into a byte[] that contains 2's complement of 
// this BigInteger
byte[] b_arr = b_int.toByteArray();
for (int i = 0; i < b_arr.length; ++i)
System.out.println("b_int.toByteArray(): " + b_arr[i] + " ");
}
}

Output

輸出量

b_int.toByteArray(): 0 
b_int.toByteArray(): -111 

翻譯自: https://www.includehelp.com/java/biginteger-tobytearray-method-with-example.aspx

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

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

相關文章

007_Web to lead

轉載于:https://www.cnblogs.com/bandariFang/p/6229491.html

設置header_Nginx的這些安全設置,你都知道嗎?

Nginx 是最流行的 Web 服務器&#xff0c;可以只占用 2.5 MB 的內存&#xff0c;卻可以輕松處理 1w 的 http 請求。做為網站的入口&#xff0c;Nginx 的安全設置重要性不言而喻。下面帶你一起去認識一下這些安全配置吧&#xff01;nginx.conf是 Nginx 最主要的配置文件&#xf…

動態路由協議_動態路由協議的類別

動態路由協議Dynamic routing protocols have been divided into 2 categories i.e Distance vector protocols and Link state protocols. Both of these protocols are being explained in detail in this tutorial. 動態路由協議分為距離矢量協議和鏈路狀態協議兩大類 。 本…

docker鏡像創建與優化

1 . 創建鏡像 有兩種方法構建鏡像&#xff1a; docker commit &#xff1a;將運行的容器保存成鏡像Dockerfile&#xff1a;自動構建 使用docker commit 創建鏡像分為三步&#xff1a; 運行容器修改容器將容器保存為鏡像 舉例&#xff1a; [rootdocker ~]# docker load -i…

ISP運營商實驗室測試機架拓撲搭建經驗分享

大家好&#xff0c;有些日子沒更新干貨了&#xff0c;近期難得有假期進行修整&#xff0c;思前顧后還是坐下來聊聊自己長期負責維護和搭建的實驗室環境。廢話不多說&#xff0c;直接上圖。因為圖較大&#xff0c;分上下部分進行上傳。網絡主框架&#xff08;上&#xff09;服務…

關于二手交易用戶指南怎么寫_讓用戶拍案叫絕文案怎么寫?試試這3個方法

“共鳴”到底是什么&#xff1f; 為什么有些文章會引起共鳴&#xff0c;而有些則沒有。現在假設為產品家用手持式美容儀寫一份副本。 由于主要重點是“家庭使用”&#xff0c;因此您立即想到了“家庭美容”的口號。 盡管這句話很簡單易懂&#xff0c;但談論起來總是很簡單……似…

結構化程序goto語句_C ++ goto語句| 查找輸出程序| 套裝1

結構化程序goto語句Program 1: 程序1&#xff1a; #include <iostream>#include <math.h>using namespace std;int main(){int num1 1;int num2 0;MY_LABEL:num2 num1 * num1;cout << num2 << " ";num1 num1 pow(2, 0);if (num1 < …

docker倉庫搭建、加密、用戶認證

1 . 含義及理解&#xff1a; 倉庫分為公開倉庫&#xff08;Public&#xff09;和私有倉庫&#xff08;Private&#xff09;兩種形式。最大的公開倉庫是 Docker Hub&#xff0c;存放了數量龐大的鏡像供用戶下載。 國內的公開倉庫包括 Docker Pool等&#xff0c;可以提供大陸用戶…

Centos7+Nginx+Keepalived實現Apache服務的高可用負載均衡

Centos7NginxKeepalived實現Apache服務的高可用&負載均衡今天是2017年的第一天&#xff0c;昨天也就是2016年的最后一天&#xff0c;我嘗試部署了Centos7NginxKeepalived實現WEB服務的高可用負載均衡服務&#xff0c;終于在2017年的第一天前完成了&#xff0c;所以在此分享…

客戶端通過網口啟動可過去的ip_西安交通大學16年3月課程考試《網絡組網技術綜合訓練》作業考核試題...

西安交通大學16年3月課程考試《網絡組網技術綜合訓練》作業考核試題一、單選題(共 20 道試題&#xff0c;共 40 分。)V 1. 下列不屬于服務器內部結構的是()A. CPUB. 電源C. 5類雙絞線D. 北橋芯片滿分&#xff1a;2 分2. 網絡中使用光纜的優點是()A. 便宜B. 容易安裝C. 是一個工…

mcq 隊列_MCQ | 軟件工程基礎知識/簡介(1)

mcq 隊列Q1. Which of the following is a part of the software? Q1。 以下哪個是軟件的一部分&#xff1f; Programs 程式 Documentation 文獻資料 Operating Procedures 運營流程 All of the above 上述所有的 Answer: d. All of the above 答案&#xff1a; d。 上述所有…

docker設置鏡像加速器

設置鏡像加速器 一般情況下&#xff0c;直接從官方倉庫中直接拉取鏡像會比較慢&#xff0c;可以設置鏡像加速器&#xff0c;相當于一個反向代理。以阿里云為例 1 . 首先獲取自己的加速器地址 www.aliyun.com 登陸自己的賬號&#xff08;可以是支付寶賬號&#xff09; 首頁點…

keytool條目_java keytool 常用命令

最近在做ssl連接active directory&#xff0c; 遇到了不少的ssl的問題。連接ssl時會需要用將證書保存到keystore&#xff0c; 而這個步驟剛好就用到了keytool命令。直接敲keytool會有提示如何用這個命令&#xff0c; 但對于完全不懂的我&#xff0c;還是找了下基本命令&#xf…

用JavaScript中的示例進行fill()函數

fill() is a predefined function in JavaScript, which is used to fill all elements of an array with a static value. fill()是JavaScript中的預定義函數&#xff0c;用于用靜態值填充數組的所有元素。 Example: 例&#xff1a; <html><head><title>J…

談談重載(overload)覆蓋(override)與隱藏

這三個概念都是與OO中的多態有關系的。如果單是區別重載與覆蓋這兩個概念是比較容易的&#xff0c;但是隱藏這一概念卻使問題變得有點復雜了&#xff0c;下面說說它們的區別吧。重載是指不同的函數使用相同的函數名&#xff0c;但是函數的參數個數或類型不同。調用的時候根據函…

搭建Harbor私有倉庫

1 首先裝好docker&#xff1a; 由于之前已安裝過&#xff0c;所以直接開起就行 2 . 安裝python2.7以上版本 之前編譯安裝過7.3的&#xff0c;直接用吧 3 . 安裝docker-compose docker容器管理工具&#xff0c;是habor的依賴之一。 curl -L "https://github.com/docker…

mysql日志查詢指令_MySQL查詢日志總結

MySQL查詢日志介紹MySQL的查詢日志記錄了所有MySQL數據庫請求的信息。無論這些請求是否得到了正確的執行。默認文件名為hostname.log。默認情況下MySQL查詢日志是關閉的。生產環境&#xff0c;如果開啟MySQL查詢日志&#xff0c;對性能還是有蠻大的影響的。另外很多時候&#x…

thinkphp5.0助手函數占用服務器資源

db(user) 默認情況下&#xff0c;每次請求都會重新連接數據庫&#xff0c;這樣會占用服務器資源 方法1.如果不想每次都重連可以這樣 db("List",[],false) 方法2.還可以直接改function&#xff0c;及則需要把 function db($name , $config [], $force true){retu…

python 無符號整數_Python中的有符號和無符號整數數組

python 無符號整數An array can be declared by using "array" module in Python. 可以通過在Python中使用“數組”模塊來聲明數組 。 Syntax to import "array" module: 導入“數組”模塊的語法&#xff1a; import array as array_alias_nameHere, imp…

mysql快速批量入庫_MySQL-批量入庫優化

MySQL批量入庫的方式循環一條一條入庫批量入庫通過程序組合 insert into (字段) tbl vlaues(), vlaues(), vlaues(),...事務入庫$autoCommit (isset($this->startTransaction) ? !$this->startTransaction : true);$ids array();if ($autoCommit) {$this->startTra…