當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。