当前位置: 首页>>代码示例>>Java>>正文


Java MathContext类代码示例

本文整理汇总了Java中java.math.MathContext的典型用法代码示例。如果您正苦于以下问题:Java MathContext类的具体用法?Java MathContext怎么用?Java MathContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MathContext类属于java.math包,在下文中一共展示了MathContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testItem_0523

import java.math.MathContext; //导入依赖的package包/类
public void testItem_0523()
{
  boolean caught;
  caught = false;
  try {
    rc_BigDecimal = new BigDecimal("UBI84SBSU744YNY9HCHKAUJSRYFATK13OIHLG9B4NLV", new MathContext("precision=0 roundingMode=HALF_EVEN"));
  }
  catch (java.lang.NumberFormatException e) {
    caught = true;
  }
  Assert.assertEquals("91.61073825503355%", true, caught);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-systemtest,代码行数:13,代码来源:TestSuite015.java

示例2: testItem_0717

import java.math.MathContext; //导入依赖的package包/类
public void testItem_0717()
{
  boolean caught;
  caught = false;
  try {
    rc_MathContext = new MathContext(-1);
  }
  catch (java.lang.IllegalArgumentException e) {
    caught = true;
  }
  Assert.assertEquals("91.94630872483222%", true, caught);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-systemtest,代码行数:13,代码来源:TestSuite061.java

示例3: testItem_0641

import java.math.MathContext; //导入依赖的package包/类
public void testItem_0641()
{
  boolean caught;
  caught = false;
  try {
    rc_MathContext = new MathContext(-2147483648);
  }
  catch (java.lang.IllegalArgumentException e) {
    caught = true;
  }
  Assert.assertEquals("85.57046979865771%", true, caught);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-systemtest,代码行数:13,代码来源:TestSuite001.java

示例4: testItem_0361

import java.math.MathContext; //导入依赖的package包/类
public void testItem_0361()
{
  boolean caught;
  caught = false;
  try {
    rc_BigDecimal = new BigDecimal("", new MathContext("precision=1 roundingMode=HALF_UP"));
  }
  catch (java.lang.NumberFormatException e) {
    caught = true;
  }
  Assert.assertEquals("91.61073825503355%", true, caught);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-systemtest,代码行数:13,代码来源:TestSuite010.java

示例5: testItem_0903

import java.math.MathContext; //导入依赖的package包/类
public void testItem_0903()
{
  boolean caught;
  caught = false;
  try {
    rc_BigDecimal = new BigDecimal(new char[]{'\1'}, new MathContext("precision=0 roundingMode=HALF_UP"));
  }
  catch (java.lang.NumberFormatException e) {
    caught = true;
  }
  Assert.assertEquals("91.94630872483222%", true, caught);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-systemtest,代码行数:13,代码来源:TestSuite050.java

示例6: testItem_0574

import java.math.MathContext; //导入依赖的package包/类
public void testItem_0574()
{
  boolean caught;
  caught = false;
  try {
    rc_BigDecimal = new BigDecimal(new char[]{'\234', '\1', '8', '\234', '\234', '\234', '\234', '8', '\1', '\1', '\0', '\uFFFF', '8', '\0', '\234', '\1', '\1', '\234', '\234', '\0', '\1', '\uFFFF', '\uFFFF', '\234', '8', '\uFFFF', '8', '\uFFFF', '\uFFFF', '\234', '\0', '\0', '\234', '\1', '\234', '\0', '\0', '\234', '\1', '8', '\0', '\1', '8', '\234', '\uFFFF', '\234', '8', '\0', '\1', '\234', '\0', '\0', '\0', '8', '8', '\1', '\234', '\0', '\uFFFF', '\234', '\0', '\1', '\1', '\234', '\1', '\0', '\uFFFF', '\uFFFF'}, new MathContext("precision=1 roundingMode=CEILING"));
  }
  catch (java.lang.NumberFormatException e) {
    caught = true;
  }
  Assert.assertEquals("91.94630872483222%", true, caught);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-systemtest,代码行数:13,代码来源:TestSuite051.java

示例7: testItem_0952

import java.math.MathContext; //导入依赖的package包/类
public void testItem_0952()
{
  boolean caught;
  caught = false;
  try {
    rc_BigDecimal_array = (new BigDecimal("-10")).divideAndRemainder(new BigDecimal("0"), new MathContext("precision=0 roundingMode=HALF_EVEN"));
  }
  catch (java.lang.ArithmeticException e) {
    caught = true;
  }
  Assert.assertEquals("91.94630872483222%", true, caught);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-systemtest,代码行数:13,代码来源:TestSuite053.java

示例8: testItem_0034

import java.math.MathContext; //导入依赖的package包/类
public void testItem_0034()
{
  boolean caught;
  caught = false;
  try {
    rc_MathContext = new MathContext(-1, java.math.RoundingMode.HALF_DOWN);
  }
  catch (java.lang.IllegalArgumentException e) {
    caught = true;
  }
  Assert.assertEquals("91.94630872483222%", true, caught);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-systemtest,代码行数:13,代码来源:TestSuite019.java

示例9: testItem_0541

import java.math.MathContext; //导入依赖的package包/类
public void testItem_0541()
{
  boolean caught;
  caught = false;
  try {
    rc_BigDecimal = new BigDecimal("N30=9D3=CYSF", new MathContext("precision=2147483647 roundingMode=HALF_UP"));
  }
  catch (java.lang.NumberFormatException e) {
    caught = true;
  }
  Assert.assertEquals("91.94630872483222%", true, caught);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-systemtest,代码行数:13,代码来源:TestSuite033.java

示例10: testItem_0595

import java.math.MathContext; //导入依赖的package包/类
public void testItem_0595()
{
  boolean caught;
  caught = false;
  try {
    rc_BigDecimal = (new BigDecimal("-0.1")).remainder(new BigDecimal("0"), new MathContext("precision=2147483647 roundingMode=HALF_UP"));
  }
  catch (java.lang.ArithmeticException e) {
    caught = true;
  }
  Assert.assertEquals("91.94630872483222%", true, caught);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-systemtest,代码行数:13,代码来源:TestSuite033.java

示例11: testItem_0415

import java.math.MathContext; //导入依赖的package包/类
public void testItem_0415()
{
  boolean caught;
  caught = false;
  try {
    rc_BigDecimal = new BigDecimal(new char[]{'\234', '\234', '\1', '\234', '\1', '\234', '\uFFFF', '\234', '\234', '\uFFFF', '8', '\234', '\234', '\0', '\1', '8', '8', '\0', '\0', '\0', '\0', '\1', '\0', '\0', '\uFFFF', '\uFFFF', '\234', '\0', '\0', '8', '8', '8', '8', '\0', '\uFFFF', '8', '8', '\0', '8', '8', '\0', '\uFFFF', '\0', '\uFFFF', '8', '\234', '\uFFFF', '\234', '\0', '\234', '\uFFFF', '\0', '8', '8'}, new MathContext("precision=2147483647 roundingMode=HALF_UP"));
  }
  catch (java.lang.NumberFormatException e) {
    caught = true;
  }
  Assert.assertEquals("91.94630872483222%", true, caught);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-systemtest,代码行数:13,代码来源:TestSuite034.java

示例12: testItem_0092

import java.math.MathContext; //导入依赖的package包/类
public void testItem_0092()
{
  boolean caught;
  caught = false;
  try {
    rc_BigDecimal = (new BigDecimal("2E+9")).pow(-2147483648, new MathContext("precision=2147483647 roundingMode=HALF_DOWN"));
  }
  catch (java.lang.ArithmeticException e) {
    caught = true;
  }
  Assert.assertEquals("91.94630872483222%", true, caught);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-systemtest,代码行数:13,代码来源:TestSuite046.java

示例13: testItem_0394

import java.math.MathContext; //导入依赖的package包/类
public void testItem_0394()
{
  boolean caught;
  caught = false;
  try {
    rc_BigDecimal = new BigDecimal(new char[]{'\0', '\uFFFF', '\234', '\uFFFF', '\1', '\234', '\234', '8', '\uFFFF', '\uFFFF', '\1', '\uFFFF', '\0', '\234', '\0', '\234', '\234', '\uFFFF', '\234', '\uFFFF', '8', '\234', '8', '\1', '\234', '8', '\1', '\0', '\234', '\uFFFF', '8', '\uFFFF', '\0', '\1', '\0', '\uFFFF', '8', '\0', '\uFFFF', '\uFFFF', '\234', '\uFFFF', '8', '\1', '\234', '\uFFFF', '8', '\uFFFF', '\234', '\0', '8', '\uFFFF', '8', '\234', '\0', '\0', '8', '8', '\1', '8', '\234', '\uFFFF', '8', '\1', '\1', '\1', '\uFFFF', '\1', '\1', '8', '8', '8', '\0', '\234', '\1', '\uFFFF', '\1', '\1', '\1', '\234', '\0', '8', '\1', '\1', '\0', '8', '\uFFFF', '\234', '\1', '\uFFFF', '\uFFFF', '\uFFFF', '\1', '8', '\1', '\0', '\uFFFF', '\234', '\0', '\0'}, new MathContext("precision=0 roundingMode=FLOOR"));
  }
  catch (java.lang.NumberFormatException e) {
    caught = true;
  }
  Assert.assertEquals("90.93959731543625%", true, caught);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-systemtest,代码行数:13,代码来源:TestSuite008.java

示例14: testItem_0418

import java.math.MathContext; //导入依赖的package包/类
public void testItem_0418()
{
  boolean caught;
  caught = false;
  try {
    rc_MathContext = new MathContext(-2147483648, java.math.RoundingMode.CEILING);
  }
  catch (java.lang.IllegalArgumentException e) {
    caught = true;
  }
  Assert.assertEquals("89.93288590604027%", true, caught);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-systemtest,代码行数:13,代码来源:TestSuite003.java

示例15: testItem_0077

import java.math.MathContext; //导入依赖的package包/类
public void testItem_0077()
{
  boolean caught;
  caught = false;
  try {
    rc_BigDecimal = new BigDecimal(new char[]{'8', '\uFFFF', '\0', '8', '\0', '\uFFFF', '\1', '\uFFFF', '\uFFFF', '\1', '\234', '\234', '\1', '\0', '\1', '\1', '8', '\234', '\1', '\uFFFF', '\0', '\uFFFF', '\0', '\234', '\uFFFF', '\0', '\0', '\1', '\234', '8', '\1', '\0', '8', '\1', '8', '8', '\234', '\0', '\234', '\1', '\0', '\1', '8', '\0', '\1', '\0', '\uFFFF', '8', '\1', '\0', '\1', '\0', '\uFFFF', '8', '\uFFFF', '\1', '8', '\uFFFF', '\1', '8', '\uFFFF', '\234', '\0', '\uFFFF', '\0', '\0', '\uFFFF', '8', '\234', '\0', '\234', '8', '\1', '8', '\0', '\234', '8', '\234', '\uFFFF', '8', '\uFFFF', '\0', '\234', '\1', '8', '\0', '\uFFFF', '\234', '8', '\uFFFF', '8', '\uFFFF', '\1', '\1', '\0', '\uFFFF', '\uFFFF', '\234', '\0', '\234'}, -2147483648, -1, new MathContext("precision=2147483647 roundingMode=FLOOR"));
  }
  catch (java.lang.NumberFormatException e) {
    caught = true;
  }
  Assert.assertEquals("91.94630872483222%", true, caught);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-systemtest,代码行数:13,代码来源:TestSuite024.java


注:本文中的java.math.MathContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。