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的更多相关文章

  1. Java 大数类BigInteger和BigDecimal的基本函数

    在Java中有两个类BigInteger和BigDecimal分别表示不可变的任意精度的整数和不可变的有符号的任意精度的十进制数(浮点数).主要用于高精度计算中.这两个类使得java中的大数,高精度运 ...

  2. Java中的大数处理类BigInteger和BigDecimar浅析

    这两个类位于java.math包内,要使用它们必须在类前面引用该包:import java.math.BigInteger;和import java.math.BigDecimal; BigInteg ...

  3. 高精度计算的类(BigInteger和BigDecimal)

    这两个类 在Java中没有对应的基本类型.不过,这两个类包含的方法,提供的操作与对基本类型所能执行的操作差不多. 也就是说,能对基本类型 int float 等的操作,也同样能作用于这两个类,只不过必 ...

  4. Java基础学习笔记之:System类;Math类;Arrays类BigInteger,BigDecimal

    System类 在API中System类介绍的比较简单,我们给出定义,System中代表程序所在系统,提供了对应的一些系统属性信息,和系统操作.System类不能手动创建对象,因为构造方法被priva ...

  5. Java大数类 BigInteger

    package bigint; /** * This class encapsulates a BigInteger, i.e. a positive or negative integer * wi ...

  6. 用Java的大整数类BigInteger来实现大整数的一些运算

    关于BigInteger的构造函数,一般会用到两个: BigInteger(String val); //将指定字符串转换为十进制表示形式: BigInteger(String val,int rad ...

  7. Java大数处理类:BigInteger类和BigDecimal类

    当我们要处理非常大的数据时,平常用的数据类型已不足以表示,在Java中有两个类BigInteger和BigDecimal分别表示大整数类和大浮点数类,这两个类在理论上只要计算机内存足够大就能够表示无线 ...

  8. BigInteger类(高精度整型)

    位置:java.math.BigInteger 作用:提供高精度整型数据类型及相关操作 一.基本介绍 BigInteger为不可变的任意精度的整数(对象创建后无法改变,每次运算均会产生一个新的对象). ...

  9. 拯救你丢失的精度——BigInteger和BigDecimal类(入门)

    第三阶段 JAVA常见对象的学习 BigInteger和BigDecimal类 BigInteger类 (一) 构造方法: //针对超过整数范围的运算(整数最大值:2147483647) BigInt ...

随机推荐

  1. 锋利的jQuery ——jQuery中的事件和动画(四)

    一.jQuery中的事件 1)加载DOM $(document).ready()和window.onload的区别 1>执行时机 $(document).ready(){}  方法内注册的事件, ...

  2. HTML第一课(前期知识准备)

    在正式的学习之前,我们先了解一些前端方面的常识. 一.前端是做什么? 如果有认真看过我写的预备程序员不得不知道的事儿这篇文章的同学应该清楚,前端的工作在整个项目开发中处于代码编写阶段,主要是用来做界面 ...

  3. CABasicAnimation animationWithKeyPath Types

    转自:http://www.cnblogs.com/pengyingh/articles/2379631.html CABasicAnimation animationWithKeyPath 一些规定 ...

  4. lspci - 列出所有PCI设备

    总览 SYNOPSIS lspci [options] 描述 DESCRIPTION lspci 是一个用来显示系统中所有PCI总线设备或连接到该总线上的所有设备的工具. 为了能使用这个命令所有功能, ...

  5. 十大基本功之testbench

      1. 激励的产生 对于testbench而言,端口应当和被测试的module一一对应.端口分为input,output和inout类型产生激励信号的时候,input对应的端口应当申明为reg, o ...

  6. C Makefile初学基础

    # this is make file hello.out: max.o min.o hello.c gcc max.o min.o hello.c -o hello.out max.o:max.c ...

  7. 计蒜客 蓝桥模拟 G. 数列求值

    递归式移项得Ai+1 = 2Ai + 2Ci - Ai-1; 1.A2 = 2A1 + 2C1 - A0; 2.A3 = 2A2 + 2C2 - A1; . . . n.An+1 = 2An + 2C ...

  8. 两张图理解nodeJS

  9. shell中通过读取输入yes no判断下一步如何处理

    if [ -d $r_item_rmgit ];then                            read -p "$r_item_rmgit exit, replace it ...

  10. Centos修改默认运行级别

    一.centos默认运行级别 下面是linux的默认运行级别.vim /etc/inittab即可查看. # Default runlevel. The runlevels used are: # - ...