Java BigInteger類| 帶有示例的減去()方法

BigInteger類減去()方法 (BigInteger Class subtract() method)

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

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

  • subtract() method is used to subtract the given value from the value of this BigInteger.

    exclude()方法用于從此BigInteger的值中減去給定值。

  • subtract() 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.

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

  • subtract() method does not throw an exception at the time of performing subtraction.

    減去()方法在執行減法時不會引發異常。

Syntax:

句法:

    public BigInteger subtract(BigInteger val);

Parameter(s):

參數:

  • BigInteger val – represents the value to be subtracted from this BigInteger.

    BigInteger val –表示要從此BigInteger中減去的值。

Return value:

返回值:

The return type of this method is BigInteger, it returns BigInteger that holds the value subtracted the given val from the value of this object.

此方法的返回類型為BigInteger ,它返回BigInteger,其中保存有從該對象的值中減去給定val的值。

Example:

例:

// Java program to demonstrate the example 
// of BigInteger subtract(BigInteger val)
// method of BigInteger
import java.math.*;
public class SubstractOfBI {
public static void main(String args[]) {
// Initialize two variables str1 str2 
String str1 = "1245";
String str2 = "100";
// Initialize two BigInteger objects  
BigInteger b_int1 = new BigInteger(str1);
BigInteger b_int2 = new BigInteger(str2);
// Display b_int1 , b_int2 
System.out.println("b_int1: " + b_int1);
System.out.println("b_int2: " + b_int2);
// subtracts the given BigInteger (b_int2)
// from this BigInteger (b_int1) i.e.
// {b_int1 - b_int2}
BigInteger sub_val = b_int1.subtract(b_int2);
System.out.println("b_int1.subtract(b_int2): " + sub_val);
}
}

Output

輸出量

b_int1: 1245
b_int2: 100
b_int1.subtract(b_int2): 1145

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

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

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

相關文章

php刪除第一個字母,php – 正在上傳的文件將第一個字母切斷

我正在將網站從具有WS2003,IIS6,PHP 5.2的服務器遷移到具有WS2008,IIS7和PHP 5.3的服務器我有一個html表單,上傳文件到網站.if(isset($_POST["Upload"])){echo "";print_r($_POST);print_r($_FILES);echo "";}?>在舊服務器上工作得很好,但在…

.7z.001,.7z.002這樣的文件如何解壓

1 如圖所示,壓縮分卷沒有顯示關聯的軟件來打開,Winrar右擊也無法解壓 2 可以使用7-ZIP軟件打開該文件,然后選擇提取(相當于Winrar的解壓),然后選擇提取路徑,默認是同一個文件夾,點擊…

二進制 |_元二進制搜索| 單邊二元搜索

二進制 & |Meta Binary Search is a one-sided binary search where we work on the index using bit manipulation. We are to find the target index by using bit manipulation like the below example where the algorithm is explained. 元二進制搜索是一種單面二進制…

codeMirror配置

介紹 CodeMirror是一款在線的支持語法高亮的代碼編輯器。官網:http://codemirror.net/ 下載后,解壓開到的文件夾中,lib下是放的是核心庫和核心css,模式下放的是各種支持語言的語法定義,主題目錄下是支持的主題樣式。一…

應夢框架9.0框架_.Net框架能力問題和解答

應夢框架9.0框架This section contains Aptitude Questions and Answers on .Net Framework. 本節包含有關.Net Framework的能力問題和解答。 1) There are the following options are given below, what are parts of the .NET Framework? FCL (Framework Class Library)Web…

php中文網視頻放不了,【雜談】看php中文網視頻課程的正確姿勢!

看在線課程如何集中精力學習?ki4網為你分享看ki4網視頻課程的正確姿勢!不談理論給些實用建議,可以根據你的情況多嘗試,看看哪條對你有用!1、選一門自己有興趣而且教師講得好的課程。(點擊學習:ki4網視頻教程…

算法筆記_065:分治法求逆序對(Java)

目錄 1 問題描述 2 解決方案 2.1 蠻力法 2.2 分治法(歸并排序) 1 問題描述 給定一個隨機數數組,求取這個數組中的逆序對總個數。要求時間效率盡可能高。 那么,何為逆序對? 引用自百度百科: 設 A 為一個有 n…

c#copyto_String.CopyTo()方法以及C#中的示例

c#copytoC#String.CopyTo()方法 (C# String.CopyTo() Method) String.CopyTo() method is used to copy a specified number of characters from given indexes of the string to the specified position in a character array. String.CopyTo()方法用于將指定數量的…

怎么查看我的php版本,怎樣查看php版本

怎樣查看php版本方法一:命令行查詢如果已經配置好環境變量,直接在命令行中輸入php -v,將會顯示php的版本信息。如果沒有配置環境變量,直接在命令行中進入到php的安裝目錄后,再輸入命令php -v,如圖所示是我在…

c ++ 繼承_C ++繼承| 查找輸出程序| 套裝1

c 繼承Program 1: 程序1&#xff1a; #include <iostream>#include <string.h>using namespace std;class Person {char name[15];int age;public:void SetPerson(int age, char* name){this->age age;strcpy(this->name, name);}};class Student : publi…

xor在PHP是什么意思,?=‘在PHP中是什么意思?

萬千封印因為它不會增加任何價值echo&#xff0c;我認為您希望了解PHP中的確切含義&#xff1a;Array([0] > Array([0] > 368 // T_OPEN_TAG_WITH_ECHO[1] > [2] > 1)[1] > Array([0] > 309 // T_VARIABLE[1] > $a [2] > 1)[2] > ; // U…

php curl keepalive,HTTPKeepAlive,開啟還是關閉

所謂「HTTP Keep-Alive」&#xff0c;在維基百科里稱為「HTTP Persistent Connection」&#xff0c;說白了就是復用HTTP連接&#xff0c;如此一來理論上客戶端的用戶體驗會更流暢&#xff0c;但是與之相對服務端不得不維持大量的連接。開啟還是關閉&#xff0c;這是個問題。一個…

如何使用ES6中的參數

ECMAScript 6&#xff08;或者叫 ECMAScript 2015&#xff09;是 ECMAScript 的最新標準&#xff0c;極大的提高了 JavaScript 中處理參數的能力。現在我們可以使用 rest 參數&#xff08;rest parameters&#xff09;、默認值&#xff08;default values&#xff09;和解構&am…

c++中tle是什么意思_如何在競爭性編程中克服TLE?

c中tle是什么意思什么是TLE&#xff1f; (What is TLE?) TLE means "Time Limit Exceed". So, in competitive programming, there are some constraints with a specific time limit (normally for each input 1 sec) and your task is to write your code in such…

美顏相機window 開源_X-Window系統| 免費和開源軟件

美顏相機window 開源X窗口系統 (The X-Window System) The X-Window System is a GUI that sits over Linux. Not at all like Microsoft Windows, the X Window System can glance and work in an enormously wide range of ways. It can work smoothly or lag, look excellen…

php 代碼 自動檢查工具下載,PHP_CodeSniffer安裝和使用教程(自動代碼檢查規范工具)...

在我們開發中都會講究代碼規范&#xff0c;若是個人開發者&#xff0c;代碼規范與否&#xff0c;只要自己看得懂便可以了&#xff0c;但是在團隊協作中&#xff0c;代碼規定尤為重要&#xff0c;下面&#xff0c;我們介紹一款PHP_CodeSniffer&#xff0c;自動檢查代碼規范的工具…

國際象棋之跳馬程序

問題描述: 假設國際象棋棋盤有5*5共25個格子。設計一個程序,使棋子從初始位置&#xff08;棋盤格編號為1的位置)開始跳馬,能夠把棋盤的格子全部走一遍,每個格子只允許走一次。要求: 1) 輸出一個解(用二維數組來記錄馬跳的過程,即[步號,棋盤格編號],左上角為第一步起點)&#xf…

kafka安裝使用

版本&#xff1a;kafka_2.11-0.10.1.0 (之前安裝2.10-0.10.0.0&#xff0c;一直出問題) 安裝Springboot結合Kafka的使用安裝 下載并解壓代碼 wget http://mirrors.cnnic.cn/apache/kafka/0.10.0.0/kafka_2.10-0.10.0.0.tgz #http://kafka.apache.org/downloadstar -zxvf kafka…

php獲取上傳文件路徑 fakepath,JavaScript_js獲取上傳文件的絕對路徑實現方法,在html中input type=file - phpStudy...

js獲取上傳文件的絕對路徑實現方法在html中function upload() {var filename document.getElementById("importFile").value;// 這時的filename不是 importFile 框中的值alert(filename);}如上面的代碼&#xff0c;用文件上傳對話框選擇文件后&#xff0c;如果選擇&…

在Bootstrap中使用類的按鈕類型

Bootstrap has 7 different types of buttons with contextual classes from which we can create buttons easily by using these classes (.btn-default, .btn-success, .btn-danger, .btn-primary, .btn-info, .btn-warning, .btn-link). Bootstrap具有上下文類型的 7種不同…