大数字运算, BigInteger
package com.ykmimi.test1; import java.math.BigInteger; /**
* 大数字运算
* @author ukyor
*
*/
public class BigNumber { public static void main(String[] args) {
//实例化一个大数字 将十进制4转换为BigInteger形式.
BigInteger bigInstance = new BigInteger("4");
//取该大数字加2的操作
BigInteger bigInstanceAdd = bigInstance.add(new BigInteger("2"));
System.out.println(bigInstance+"+2="+bigInstanceAdd);
//取该大数字减3的操作
BigInteger bigInstanceSubtract = bigInstance.subtract(new BigInteger("3"));
System.out.println(bigInstance+"-3="+bigInstanceSubtract);
//取该大数字乘以2的操作
BigInteger bigInstanceMultiply = bigInstance.multiply(new BigInteger("2"));
System.out.println(bigInstance+"*2="+bigInstanceMultiply);
//取该大数字除以2的操作
BigInteger bigInstanceDivide = bigInstance.divide(new BigInteger("2"));
System.out.println(bigInstance+"/2="+bigInstanceDivide);
//取除商
System.out.println("4/3的商为"+bigInstance.divideAndRemainder(new BigInteger("3"))[0]);
//取余数
System.out.println("4/3的余数为"+bigInstance.divideAndRemainder(new BigInteger("3"))[1]);
//取该大数字的次方
System.out.println("4的3次方为"+bigInstance.pow(3));
//取该大数字的相反数
System.out.println("4的相反数为"+bigInstance.negate());
}
}
大数字运算, BigInteger的更多相关文章
- 大数字运算——2、BigDecimal
package com.wh.BigInteger; import java.math.BigDecimal; import java.util.Arrays; /** * @author 王恒 * ...
- 初识Java(Java数字处理类-大数字运算)
一.大数字运算 在 Java 中提供了大数字的操作类,即 java.math.BigInteger 类与 java.math.BigDecimal 类.这两个类用于高精度计算,体重 BigInteg ...
- 学习Java的第十七天——大数字运算
学习内容:大数字运算 代码实现: package 数字处理类; import java.math.BigInteger; public class BigIntegerDemo { public st ...
- 大数字运算——1、BigInteger
package com.wh.BigInteger; import java.math.BigInteger; import java.util.Arrays; /** * @author 王恒 * ...
- java 大数据运算 BigInteger BigDecimal
package cn.sasa.demo5; import java.math.BigDecimal; import java.math.BigInteger; public class BigDat ...
- 7、包装类、System、Math、Arrays、大数据运算
基本类型封装 基本数据类型对象包装类概述 *A:基本数据类型对象包装类概述 *a.基本类型包装类的产生 在实际程序使用中,程序界面上用户输入的数据都是以字符串类型进行存储的.而程序开发中,我们需要把字 ...
- java学习第13天( java获取当前时间,有关大数据的运算及精确数字运算,Date类)
一 java获取当前时间 学习一个函数,得到当前时间的准确值 System.currectTimeMillis(). 可以得到以毫秒为单位的当前时间.它主要用于计算程序运行时间,long start= ...
- C#实现大数字的运算
1.添加引用:System.Numerics.dll 2.添加命名空间:using System.Numerics; 3.实例: 3.1判断一个数字是不是质数 static void Main(str ...
- java大数字操作:BigInteger,BigDecimal(浮点型)
java大数字操作: BigInteger:大数字整型的 BigDecimal(浮点型):大数字小数的,也适用大的整数 BigInteger: String num1 = "10038182 ...
随机推荐
- requesMapping注解
java类 package org.springframework.web.bind.annotation; import java.lang.annotation.Documented; impor ...
- 流媒体ts/ps流封装/分析
1.TS 1) 感谢星辰同学,还热乎着,
- application实例
application详解及实例 application对象用来在多个程序或者是多个用户之间共享数据,用户使用的所有application对象都是一样的,这与session对象不同.服务器一旦启动,就 ...
- gcc static静态编译选项提示错误修正(/usr/lib/ld: cannot find -lc)
用gcc静态编译C程序时显示出: /usr/lib/ld: cannot find -lc /usr/lib/ld: cannot find -lgcc_s /usr/lib/ld: cannot f ...
- nltk模块基础操作
几个基础函数 (1)搜索文本:text.concordance(word) 例如,在text1中搜索词”is”在文本中出现的次数以及上下文的词:text1.concordance("is& ...
- html05
1.js中的对象-内置对象-外部对象-自定义对象 2.常见的内置对象有哪些?-String对象-Number对象-Boolean对象-Array对象-Math对象-Date对象-RegExp正则对象- ...
- PHP获取http头信息
PHP手册提供了现成的函数: getallheaders (PHP 4, PHP 5) getallheaders — Fetch all HTTP request headers 说明 array ...
- 远程桌面时出现身份验证错误,要求的函数不正确,这可能是由于CredSSP加密Oracle修正
问题如下: 那么解决办法如下:
- 小试---EF5.0入门实例1
现在做个小练习吧~~~ 第一步:首先新建一个数据库名字为Test;数据库里面只有一个表UserTable 脚本为: USE [master] GO /****** 对象: Database [Test ...
- python webdriver firefox 登录126邮箱,先添加联系人,然后进入首页发送邮件,带附件。
代码:#encoding=utf-8from selenium import webdriverfrom selenium.webdriver.common.keys import Keysfrom ...