类BigInteger
BigInteger类
可以让超过Integer范围内的数据进行运算
构造方法
public BigIntege(String val);
package com.jacky;
import java.math.BigInteger;
public class IntegerDemo {
public static void main(String[] args) {
// TODO Auto-generated method stub
Integer i = new Integer(100);
System.out.println(Integer.MAX_VALUE);
System.out.println(Integer.MIN_VALUE);
BigInteger bi = new BigInteger("2147483648");
System.out.println("bi:" + bi);
}
}
/*
* public BigInteger add(BigInteger val);//加
* public BigInteger subtract(BigInteger val);//减
* public BigInteger multiply(BigInteger val);//乘
* public BigInteger divide(BigInteger val);//除
* public BigInteger[] divideAndRemainder(BigInteger val);//返回商和余数的数组
* */
import java.math.BigInteger; /*
* public BigInteger add(BigInteger val);//加
* public BigInteger subtract(BigInteger val);//减
* public BigInteger multiply(BigInteger val);//乘
* public BigInteger divide(BigInteger val);//除
* public BigInteger[] divideAndRemainder(BigInteger val);//返回商和余数的数组
* */ public class IntegerDemo { public static void main(String[] args) {
// TODO Auto-generated method stub BigInteger bi1 = new BigInteger("100");
BigInteger bi2 = new BigInteger("50"); System.out.println("add:" + bi1.add(bi2));
System.out.println("subtract:" + bi1.subtract(bi2));
System.out.println("multiply:" + bi1.multiply(bi2));
System.out.println("divide:" + bi1.divide(bi2)); BigInteger bis[] = bi1.divideAndRemainder(bi2);
System.out.println("商:" + bis[0]);
System.out.println("余数、:" + bis[1]);
}
}
类BigInteger的更多相关文章
- Java 大数类BigInteger和BigDecimal的基本函数
在Java中有两个类BigInteger和BigDecimal分别表示不可变的任意精度的整数和不可变的有符号的任意精度的十进制数(浮点数).主要用于高精度计算中.这两个类使得java中的大数,高精度运 ...
- Java中的大数处理类BigInteger和BigDecimar浅析
这两个类位于java.math包内,要使用它们必须在类前面引用该包:import java.math.BigInteger;和import java.math.BigDecimal; BigInteg ...
- 高精度计算的类(BigInteger和BigDecimal)
这两个类 在Java中没有对应的基本类型.不过,这两个类包含的方法,提供的操作与对基本类型所能执行的操作差不多. 也就是说,能对基本类型 int float 等的操作,也同样能作用于这两个类,只不过必 ...
- Java基础学习笔记之:System类;Math类;Arrays类BigInteger,BigDecimal
System类 在API中System类介绍的比较简单,我们给出定义,System中代表程序所在系统,提供了对应的一些系统属性信息,和系统操作.System类不能手动创建对象,因为构造方法被priva ...
- Java大数类 BigInteger
package bigint; /** * This class encapsulates a BigInteger, i.e. a positive or negative integer * wi ...
- 用Java的大整数类BigInteger来实现大整数的一些运算
关于BigInteger的构造函数,一般会用到两个: BigInteger(String val); //将指定字符串转换为十进制表示形式: BigInteger(String val,int rad ...
- Java大数处理类:BigInteger类和BigDecimal类
当我们要处理非常大的数据时,平常用的数据类型已不足以表示,在Java中有两个类BigInteger和BigDecimal分别表示大整数类和大浮点数类,这两个类在理论上只要计算机内存足够大就能够表示无线 ...
- BigInteger类(高精度整型)
位置:java.math.BigInteger 作用:提供高精度整型数据类型及相关操作 一.基本介绍 BigInteger为不可变的任意精度的整数(对象创建后无法改变,每次运算均会产生一个新的对象). ...
- 拯救你丢失的精度——BigInteger和BigDecimal类(入门)
第三阶段 JAVA常见对象的学习 BigInteger和BigDecimal类 BigInteger类 (一) 构造方法: //针对超过整数范围的运算(整数最大值:2147483647) BigInt ...
随机推荐
- TCP/IP四层协议
1.数据链路层 数据链路层实现了网卡接口的网络驱动程序,处理数据在物理媒介(以太网,令牌环)上的传输,常用协议包含ARP(地址解析协议),RARP(逆地址解析协议)两个协议,他们实现了IP地址和物理地 ...
- CSS链接使用伪类的顺序
顺序为:link-visited-hover-active a:link {color: #FF0000} /* 未访问的链接 */ a:visited {color: #00FF00} /* 已访问 ...
- HTML第一课(前期知识准备)
在正式的学习之前,我们先了解一些前端方面的常识. 一.前端是做什么? 如果有认真看过我写的预备程序员不得不知道的事儿这篇文章的同学应该清楚,前端的工作在整个项目开发中处于代码编写阶段,主要是用来做界面 ...
- Python 循环异或对文件进行加解密
# -* -coding: UTF-8 -* - # 功能:异或方式对文件进行加密和解密 import os import datetime # 主函数 def main(): getInput() ...
- memset,内存初始化函数
# include <string.h> void *memset(void *s, int c, unsigned long n); 函数的功能是:将指针变量 s 所指向的前 n 字节的 ...
- PAT Advanced 1027 Colors in Mars (20 分)
People in Mars represent the colors in their computers in a similar way as the Earth people. That is ...
- 最小可观(Minimal Observability Problem in Conjunctive Boolean Networks)
论文链接 1. 什么是 conjunctive Boolean network (CBN) 仅仅包含and运算. 下面这个式子为恒定更新函数 2. 什么是可观 定义在时刻k是CBN的状态为 X(k) ...
- linear_func
''' class torch.nn.Linear(in_features,out_features,bias = True )[来源] 参数: in_features - 每个输入样本的大小out_ ...
- python 获取系统环境变量 os.environ and os.putenv
从一段code说起 “if "BATCH_CONFIG_INI" in os.environ:” 判断环境变量的值有没有定义 如果定义的话就去环境变量的值,否则就取当前目录下的co ...
- 【hiho1044】状压dp1
题目大意:给定一个长度为 N 的序列,每个位置有一个权值,现选出一些点,满足相邻的 M 个点中至多有 Q 个点被选择,求选出点权的最大值是多少. 题解:若没有相邻的限制,这道题类似于子集和问题,即:背 ...