Java Code Examples for java.text.NumberFormat#getRoundingMode()
The following examples show how to use
java.text.NumberFormat#getRoundingMode() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TieRoundingTest.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
static void formatOutputTestLong(NumberFormat nf, long longToTest, String tiePosition, String inputDigits, String expectedOutput) { int mfd = nf.getMaximumFractionDigits(); RoundingMode rm = nf.getRoundingMode(); String result = nf.format(longToTest); if (!result.equals(expectedOutput)) { System.out.println(); System.out.println("========================================"); System.out.println("***Failure : error formatting value from string : " + inputDigits); System.out.println("NumberFormat pattern is : " + ((DecimalFormat ) nf).toPattern()); System.out.println("Maximum number of fractional digits : " + mfd); System.out.println("Fractional rounding digit : " + (mfd + 1)); System.out.println("Position of value relative to tie : " + tiePosition); System.out.println("Rounding Mode : " + rm); System.out.println( "Error. Formatted result different from expected." + "\nExpected output is : \"" + expectedOutput + "\"" + "\nFormated output is : \"" + result + "\""); System.out.println("========================================"); System.out.println(); errorCounter++; allPassed = false; } else { testCounter++; System.out.print("Success. Long input :" + inputDigits); System.out.print(", rounding : " + rm); System.out.print(", fract digits : " + mfd); System.out.print(", tie position : " + tiePosition); System.out.println(", expected : " + expectedOutput); } }
Example 2
Source File: TieRoundingTest.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
static void formatOutputTestObject(NumberFormat nf, Object someNumber, String tiePosition, String inputDigits, String expectedOutput) { int mfd = nf.getMaximumFractionDigits(); RoundingMode rm = nf.getRoundingMode(); String result = nf.format(someNumber); if (!result.equals(expectedOutput)) { System.out.println(); System.out.println("========================================"); System.out.println("***Failure : error formatting value from string : " + inputDigits); System.out.println("NumberFormat pattern is : " + ((DecimalFormat ) nf).toPattern()); System.out.println("Maximum number of fractional digits : " + mfd); System.out.println("Fractional rounding digit : " + (mfd + 1)); System.out.println("Position of value relative to tie : " + tiePosition); System.out.println("Rounding Mode : " + rm); System.out.println("Number self output representation: " + someNumber); System.out.println( "Error. Formatted result different from expected." + "\nExpected output is : \"" + expectedOutput + "\"" + "\nFormated output is : \"" + result + "\""); System.out.println("========================================"); System.out.println(); errorCounter++; allPassed = false; } else { testCounter++; System.out.print("Success. Number input :" + inputDigits); System.out.print(", rounding : " + rm); System.out.print(", fract digits : " + mfd); System.out.print(", tie position : " + tiePosition); System.out.println(", expected : " + expectedOutput); } }
Example 3
Source File: TieRoundingTest.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
static void formatOutputTestLong(NumberFormat nf, long longToTest, String tiePosition, String inputDigits, String expectedOutput) { int mfd = nf.getMaximumFractionDigits(); RoundingMode rm = nf.getRoundingMode(); String result = nf.format(longToTest); if (!result.equals(expectedOutput)) { System.out.println(); System.out.println("========================================"); System.out.println("***Failure : error formatting value from string : " + inputDigits); System.out.println("NumberFormat pattern is : " + ((DecimalFormat ) nf).toPattern()); System.out.println("Maximum number of fractional digits : " + mfd); System.out.println("Fractional rounding digit : " + (mfd + 1)); System.out.println("Position of value relative to tie : " + tiePosition); System.out.println("Rounding Mode : " + rm); System.out.println( "Error. Formatted result different from expected." + "\nExpected output is : \"" + expectedOutput + "\"" + "\nFormated output is : \"" + result + "\""); System.out.println("========================================"); System.out.println(); errorCounter++; allPassed = false; } else { testCounter++; System.out.print("Success. Long input :" + inputDigits); System.out.print(", rounding : " + rm); System.out.print(", fract digits : " + mfd); System.out.print(", tie position : " + tiePosition); System.out.println(", expected : " + expectedOutput); } }
Example 4
Source File: TieRoundingTest.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
static void formatOutputTestObject(NumberFormat nf, Object someNumber, String tiePosition, String inputDigits, String expectedOutput) { int mfd = nf.getMaximumFractionDigits(); RoundingMode rm = nf.getRoundingMode(); String result = nf.format(someNumber); if (!result.equals(expectedOutput)) { System.out.println(); System.out.println("========================================"); System.out.println("***Failure : error formatting value from string : " + inputDigits); System.out.println("NumberFormat pattern is : " + ((DecimalFormat ) nf).toPattern()); System.out.println("Maximum number of fractional digits : " + mfd); System.out.println("Fractional rounding digit : " + (mfd + 1)); System.out.println("Position of value relative to tie : " + tiePosition); System.out.println("Rounding Mode : " + rm); System.out.println("Number self output representation: " + someNumber); System.out.println( "Error. Formatted result different from expected." + "\nExpected output is : \"" + expectedOutput + "\"" + "\nFormated output is : \"" + result + "\""); System.out.println("========================================"); System.out.println(); errorCounter++; allPassed = false; } else { testCounter++; System.out.print("Success. Number input :" + inputDigits); System.out.print(", rounding : " + rm); System.out.print(", fract digits : " + mfd); System.out.print(", tie position : " + tiePosition); System.out.println(", expected : " + expectedOutput); } }
Example 5
Source File: TieRoundingTest.java From hottub with GNU General Public License v2.0 | 5 votes |
static void formatOutputTestObject(NumberFormat nf, Object someNumber, String tiePosition, String inputDigits, String expectedOutput) { int mfd = nf.getMaximumFractionDigits(); RoundingMode rm = nf.getRoundingMode(); String result = nf.format(someNumber); if (!result.equals(expectedOutput)) { System.out.println(); System.out.println("========================================"); System.out.println("***Failure : error formatting value from string : " + inputDigits); System.out.println("NumberFormat pattern is : " + ((DecimalFormat ) nf).toPattern()); System.out.println("Maximum number of fractional digits : " + mfd); System.out.println("Fractional rounding digit : " + (mfd + 1)); System.out.println("Position of value relative to tie : " + tiePosition); System.out.println("Rounding Mode : " + rm); System.out.println("Number self output representation: " + someNumber); System.out.println( "Error. Formatted result different from expected." + "\nExpected output is : \"" + expectedOutput + "\"" + "\nFormated output is : \"" + result + "\""); System.out.println("========================================"); System.out.println(); errorCounter++; allPassed = false; } else { testCounter++; System.out.print("Success. Number input :" + inputDigits); System.out.print(", rounding : " + rm); System.out.print(", fract digits : " + mfd); System.out.print(", tie position : " + tiePosition); System.out.println(", expected : " + expectedOutput); } }
Example 6
Source File: TieRoundingTest.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
static void formatOutputTestLong(NumberFormat nf, long longToTest, String tiePosition, String inputDigits, String expectedOutput) { int mfd = nf.getMaximumFractionDigits(); RoundingMode rm = nf.getRoundingMode(); String result = nf.format(longToTest); if (!result.equals(expectedOutput)) { System.out.println(); System.out.println("========================================"); System.out.println("***Failure : error formatting value from string : " + inputDigits); System.out.println("NumberFormat pattern is : " + ((DecimalFormat ) nf).toPattern()); System.out.println("Maximum number of fractional digits : " + mfd); System.out.println("Fractional rounding digit : " + (mfd + 1)); System.out.println("Position of value relative to tie : " + tiePosition); System.out.println("Rounding Mode : " + rm); System.out.println( "Error. Formatted result different from expected." + "\nExpected output is : \"" + expectedOutput + "\"" + "\nFormated output is : \"" + result + "\""); System.out.println("========================================"); System.out.println(); errorCounter++; allPassed = false; } else { testCounter++; System.out.print("Success. Long input :" + inputDigits); System.out.print(", rounding : " + rm); System.out.print(", fract digits : " + mfd); System.out.print(", tie position : " + tiePosition); System.out.println(", expected : " + expectedOutput); } }
Example 7
Source File: TieRoundingTest.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
static void formatOutputTestObject(NumberFormat nf, Object someNumber, String tiePosition, String inputDigits, String expectedOutput) { int mfd = nf.getMaximumFractionDigits(); RoundingMode rm = nf.getRoundingMode(); String result = nf.format(someNumber); if (!result.equals(expectedOutput)) { System.out.println(); System.out.println("========================================"); System.out.println("***Failure : error formatting value from string : " + inputDigits); System.out.println("NumberFormat pattern is : " + ((DecimalFormat ) nf).toPattern()); System.out.println("Maximum number of fractional digits : " + mfd); System.out.println("Fractional rounding digit : " + (mfd + 1)); System.out.println("Position of value relative to tie : " + tiePosition); System.out.println("Rounding Mode : " + rm); System.out.println("Number self output representation: " + someNumber); System.out.println( "Error. Formatted result different from expected." + "\nExpected output is : \"" + expectedOutput + "\"" + "\nFormated output is : \"" + result + "\""); System.out.println("========================================"); System.out.println(); errorCounter++; allPassed = false; } else { testCounter++; System.out.print("Success. Number input :" + inputDigits); System.out.print(", rounding : " + rm); System.out.print(", fract digits : " + mfd); System.out.print(", tie position : " + tiePosition); System.out.println(", expected : " + expectedOutput); } }
Example 8
Source File: TieRoundingTest.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
static void formatOutputTestObject(NumberFormat nf, Object someNumber, String tiePosition, String inputDigits, String expectedOutput) { int mfd = nf.getMaximumFractionDigits(); RoundingMode rm = nf.getRoundingMode(); String result = nf.format(someNumber); if (!result.equals(expectedOutput)) { System.out.println(); System.out.println("========================================"); System.out.println("***Error formatting number value from string : " + inputDigits); System.out.println("NumberFormat pattern is : " + ((DecimalFormat ) nf).toPattern()); System.out.println("Maximum number of fractional digits : " + mfd); System.out.println("Fractional rounding digit : " + (mfd + 1)); System.out.println("Position of value relative to tie : " + tiePosition); System.out.println("Rounding Mode : " + rm); System.out.println("Number self output representation: " + someNumber); System.out.println( "Error. Formatted result different from expected." + "\nExpected output is : \"" + expectedOutput + "\"" + "\nFormated output is : \"" + result + "\""); System.out.println("========================================"); System.out.println(); errorCounter++; allPassed = false; } else { testCounter++; System.out.print("Success. Number input :" + inputDigits); System.out.print(", rounding : " + rm); System.out.print(", fract digits : " + mfd); System.out.print(", tie position : " + tiePosition); System.out.println(", expected : " + expectedOutput); } }
Example 9
Source File: TieRoundingTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
static void formatOutputTestLong(NumberFormat nf, long longToTest, String tiePosition, String inputDigits, String expectedOutput) { int mfd = nf.getMaximumFractionDigits(); RoundingMode rm = nf.getRoundingMode(); String result = nf.format(longToTest); if (!result.equals(expectedOutput)) { System.out.println(); System.out.println("========================================"); System.out.println("***Failure : error formatting value from string : " + inputDigits); System.out.println("NumberFormat pattern is : " + ((DecimalFormat ) nf).toPattern()); System.out.println("Maximum number of fractional digits : " + mfd); System.out.println("Fractional rounding digit : " + (mfd + 1)); System.out.println("Position of value relative to tie : " + tiePosition); System.out.println("Rounding Mode : " + rm); System.out.println( "Error. Formatted result different from expected." + "\nExpected output is : \"" + expectedOutput + "\"" + "\nFormated output is : \"" + result + "\""); System.out.println("========================================"); System.out.println(); errorCounter++; allPassed = false; } else { testCounter++; System.out.print("Success. Long input :" + inputDigits); System.out.print(", rounding : " + rm); System.out.print(", fract digits : " + mfd); System.out.print(", tie position : " + tiePosition); System.out.println(", expected : " + expectedOutput); } }
Example 10
Source File: TieRoundingTest.java From hottub with GNU General Public License v2.0 | 5 votes |
static void formatOutputTestLong(NumberFormat nf, long longToTest, String tiePosition, String inputDigits, String expectedOutput) { int mfd = nf.getMaximumFractionDigits(); RoundingMode rm = nf.getRoundingMode(); String result = nf.format(longToTest); if (!result.equals(expectedOutput)) { System.out.println(); System.out.println("========================================"); System.out.println("***Failure : error formatting value from string : " + inputDigits); System.out.println("NumberFormat pattern is : " + ((DecimalFormat ) nf).toPattern()); System.out.println("Maximum number of fractional digits : " + mfd); System.out.println("Fractional rounding digit : " + (mfd + 1)); System.out.println("Position of value relative to tie : " + tiePosition); System.out.println("Rounding Mode : " + rm); System.out.println( "Error. Formatted result different from expected." + "\nExpected output is : \"" + expectedOutput + "\"" + "\nFormated output is : \"" + result + "\""); System.out.println("========================================"); System.out.println(); errorCounter++; allPassed = false; } else { testCounter++; System.out.print("Success. Long input :" + inputDigits); System.out.print(", rounding : " + rm); System.out.print(", fract digits : " + mfd); System.out.print(", tie position : " + tiePosition); System.out.println(", expected : " + expectedOutput); } }
Example 11
Source File: TieRoundingTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
static void formatOutputTestObject(NumberFormat nf, Object someNumber, String tiePosition, String inputDigits, String expectedOutput) { int mfd = nf.getMaximumFractionDigits(); RoundingMode rm = nf.getRoundingMode(); String result = nf.format(someNumber); if (!result.equals(expectedOutput)) { System.out.println(); System.out.println("========================================"); System.out.println("***Failure : error formatting value from string : " + inputDigits); System.out.println("NumberFormat pattern is : " + ((DecimalFormat ) nf).toPattern()); System.out.println("Maximum number of fractional digits : " + mfd); System.out.println("Fractional rounding digit : " + (mfd + 1)); System.out.println("Position of value relative to tie : " + tiePosition); System.out.println("Rounding Mode : " + rm); System.out.println("Number self output representation: " + someNumber); System.out.println( "Error. Formatted result different from expected." + "\nExpected output is : \"" + expectedOutput + "\"" + "\nFormated output is : \"" + result + "\""); System.out.println("========================================"); System.out.println(); errorCounter++; allPassed = false; } else { testCounter++; System.out.print("Success. Number input :" + inputDigits); System.out.print(", rounding : " + rm); System.out.print(", fract digits : " + mfd); System.out.print(", tie position : " + tiePosition); System.out.println(", expected : " + expectedOutput); } }
Example 12
Source File: TieRoundingTest.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
static void formatOutputTestObject(NumberFormat nf, Object someNumber, String tiePosition, String inputDigits, String expectedOutput) { int mfd = nf.getMaximumFractionDigits(); RoundingMode rm = nf.getRoundingMode(); String result = nf.format(someNumber); if (!result.equals(expectedOutput)) { System.out.println(); System.out.println("========================================"); System.out.println("***Failure : error formatting value from string : " + inputDigits); System.out.println("NumberFormat pattern is : " + ((DecimalFormat ) nf).toPattern()); System.out.println("Maximum number of fractional digits : " + mfd); System.out.println("Fractional rounding digit : " + (mfd + 1)); System.out.println("Position of value relative to tie : " + tiePosition); System.out.println("Rounding Mode : " + rm); System.out.println("Number self output representation: " + someNumber); System.out.println( "Error. Formatted result different from expected." + "\nExpected output is : \"" + expectedOutput + "\"" + "\nFormated output is : \"" + result + "\""); System.out.println("========================================"); System.out.println(); errorCounter++; allPassed = false; } else { testCounter++; System.out.print("Success. Number input :" + inputDigits); System.out.print(", rounding : " + rm); System.out.print(", fract digits : " + mfd); System.out.print(", tie position : " + tiePosition); System.out.println(", expected : " + expectedOutput); } }
Example 13
Source File: TieRoundingTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
static void formatOutputTestLong(NumberFormat nf, long longToTest, String tiePosition, String inputDigits, String expectedOutput) { int mfd = nf.getMaximumFractionDigits(); RoundingMode rm = nf.getRoundingMode(); String result = nf.format(longToTest); if (!result.equals(expectedOutput)) { System.out.println(); System.out.println("========================================"); System.out.println("***Failure : error formatting value from string : " + inputDigits); System.out.println("NumberFormat pattern is : " + ((DecimalFormat ) nf).toPattern()); System.out.println("Maximum number of fractional digits : " + mfd); System.out.println("Fractional rounding digit : " + (mfd + 1)); System.out.println("Position of value relative to tie : " + tiePosition); System.out.println("Rounding Mode : " + rm); System.out.println( "Error. Formatted result different from expected." + "\nExpected output is : \"" + expectedOutput + "\"" + "\nFormated output is : \"" + result + "\""); System.out.println("========================================"); System.out.println(); errorCounter++; allPassed = false; } else { testCounter++; System.out.print("Success. Long input :" + inputDigits); System.out.print(", rounding : " + rm); System.out.print(", fract digits : " + mfd); System.out.print(", tie position : " + tiePosition); System.out.println(", expected : " + expectedOutput); } }
Example 14
Source File: TieRoundingTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
static void formatOutputTestObject(NumberFormat nf, Object someNumber, String tiePosition, String inputDigits, String expectedOutput) { int mfd = nf.getMaximumFractionDigits(); RoundingMode rm = nf.getRoundingMode(); String result = nf.format(someNumber); if (!result.equals(expectedOutput)) { System.out.println(); System.out.println("========================================"); System.out.println("***Failure : error formatting value from string : " + inputDigits); System.out.println("NumberFormat pattern is : " + ((DecimalFormat ) nf).toPattern()); System.out.println("Maximum number of fractional digits : " + mfd); System.out.println("Fractional rounding digit : " + (mfd + 1)); System.out.println("Position of value relative to tie : " + tiePosition); System.out.println("Rounding Mode : " + rm); System.out.println("Number self output representation: " + someNumber); System.out.println( "Error. Formatted result different from expected." + "\nExpected output is : \"" + expectedOutput + "\"" + "\nFormated output is : \"" + result + "\""); System.out.println("========================================"); System.out.println(); errorCounter++; allPassed = false; } else { testCounter++; System.out.print("Success. Number input :" + inputDigits); System.out.print(", rounding : " + rm); System.out.print(", fract digits : " + mfd); System.out.print(", tie position : " + tiePosition); System.out.println(", expected : " + expectedOutput); } }
Example 15
Source File: TieRoundingTest.java From hottub with GNU General Public License v2.0 | 4 votes |
static void formatOutputTestDouble(NumberFormat nf, double doubleToTest, String tiePosition, String inputDigits, String expectedOutput) { int mfd = nf.getMaximumFractionDigits(); RoundingMode rm = nf.getRoundingMode(); String result = nf.format(doubleToTest); if (!result.equals(expectedOutput)) { System.out.println(); System.out.println("========================================"); System.out.println("***Failure : error formatting value from string : " + inputDigits); System.out.println("NumberFormat pattern is : " + ((DecimalFormat ) nf).toPattern()); System.out.println("Maximum number of fractional digits : " + mfd); System.out.println("Fractional rounding digit : " + (mfd + 1)); System.out.println("Position of value relative to tie : " + tiePosition); System.out.println("Rounding Mode : " + rm); System.out.println("BigDecimal output : " + new BigDecimal(doubleToTest).toString()); System.out.println("FloatingDecimal output : " + doubleToTest); System.out.println( "Error. Formatted result different from expected." + "\nExpected output is : \"" + expectedOutput + "\"" + "\nFormated output is : \"" + result + "\""); System.out.println("========================================"); System.out.println(); errorCounter++; allPassed = false; } else { testCounter++; System.out.println("\nSuccess for double value : " + doubleToTest + " :"); System.out.println(" Input digits :" + inputDigits + ", BigDecimal value : " + new BigDecimal(doubleToTest).toString()); System.out.print(" Rounding mode: " + rm); System.out.print(", fract digits : " + mfd); System.out.print(", position : " + tiePosition + " tie"); System.out.print(", result : " + result); System.out.println(", expected : " + expectedOutput); } }
Example 16
Source File: TieRoundingTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
static void formatOutputTestDouble(NumberFormat nf, double doubleToTest, String tiePosition, String inputDigits, String expectedOutput) { int mfd = nf.getMaximumFractionDigits(); RoundingMode rm = nf.getRoundingMode(); String result = nf.format(doubleToTest); if (!result.equals(expectedOutput)) { System.out.println(); System.out.println("========================================"); System.out.println("***Failure : error formatting value from string : " + inputDigits); System.out.println("NumberFormat pattern is : " + ((DecimalFormat ) nf).toPattern()); System.out.println("Maximum number of fractional digits : " + mfd); System.out.println("Fractional rounding digit : " + (mfd + 1)); System.out.println("Position of value relative to tie : " + tiePosition); System.out.println("Rounding Mode : " + rm); System.out.println("BigDecimal output : " + new BigDecimal(doubleToTest).toString()); System.out.println("FloatingDecimal output : " + doubleToTest); System.out.println( "Error. Formatted result different from expected." + "\nExpected output is : \"" + expectedOutput + "\"" + "\nFormated output is : \"" + result + "\""); System.out.println("========================================"); System.out.println(); errorCounter++; allPassed = false; } else { testCounter++; System.out.println("\nSuccess for double value : " + doubleToTest + " :"); System.out.println(" Input digits :" + inputDigits + ", BigDecimal value : " + new BigDecimal(doubleToTest).toString()); System.out.print(" Rounding mode: " + rm); System.out.print(", fract digits : " + mfd); System.out.print(", position : " + tiePosition + " tie"); System.out.print(", result : " + result); System.out.println(", expected : " + expectedOutput); } }
Example 17
Source File: TieRoundingTest.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
static void formatOutputTestDouble(NumberFormat nf, double doubleToTest, String tiePosition, String inputDigits, String expectedOutput) { int mfd = nf.getMaximumFractionDigits(); RoundingMode rm = nf.getRoundingMode(); String result = nf.format(doubleToTest); if (!result.equals(expectedOutput)) { System.out.println(); System.out.println("========================================"); System.out.println("***Failure : error formatting value from string : " + inputDigits); System.out.println("NumberFormat pattern is : " + ((DecimalFormat ) nf).toPattern()); System.out.println("Maximum number of fractional digits : " + mfd); System.out.println("Fractional rounding digit : " + (mfd + 1)); System.out.println("Position of value relative to tie : " + tiePosition); System.out.println("Rounding Mode : " + rm); System.out.println("BigDecimal output : " + new BigDecimal(doubleToTest).toString()); System.out.println("FloatingDecimal output : " + doubleToTest); System.out.println( "Error. Formatted result different from expected." + "\nExpected output is : \"" + expectedOutput + "\"" + "\nFormated output is : \"" + result + "\""); System.out.println("========================================"); System.out.println(); errorCounter++; allPassed = false; } else { testCounter++; System.out.println("\nSuccess for double value : " + doubleToTest + " :"); System.out.println(" Input digits :" + inputDigits + ", BigDecimal value : " + new BigDecimal(doubleToTest).toString()); System.out.print(" Rounding mode: " + rm); System.out.print(", fract digits : " + mfd); System.out.print(", position : " + tiePosition + " tie"); System.out.print(", result : " + result); System.out.println(", expected : " + expectedOutput); } }
Example 18
Source File: TieRoundingTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
static void formatOutputTestDouble(NumberFormat nf, double doubleToTest, String tiePosition, String inputDigits, String expectedOutput) { int mfd = nf.getMaximumFractionDigits(); RoundingMode rm = nf.getRoundingMode(); String result = nf.format(doubleToTest); if (!result.equals(expectedOutput)) { System.out.println(); System.out.println("========================================"); System.out.println("***Failure : error formatting value from string : " + inputDigits); System.out.println("NumberFormat pattern is : " + ((DecimalFormat ) nf).toPattern()); System.out.println("Maximum number of fractional digits : " + mfd); System.out.println("Fractional rounding digit : " + (mfd + 1)); System.out.println("Position of value relative to tie : " + tiePosition); System.out.println("Rounding Mode : " + rm); System.out.println("BigDecimal output : " + new BigDecimal(doubleToTest).toString()); System.out.println("FloatingDecimal output : " + doubleToTest); System.out.println( "Error. Formatted result different from expected." + "\nExpected output is : \"" + expectedOutput + "\"" + "\nFormated output is : \"" + result + "\""); System.out.println("========================================"); System.out.println(); errorCounter++; allPassed = false; } else { testCounter++; System.out.println("\nSuccess for double value : " + doubleToTest + " :"); System.out.println(" Input digits :" + inputDigits + ", BigDecimal value : " + new BigDecimal(doubleToTest).toString()); System.out.print(" Rounding mode: " + rm); System.out.print(", fract digits : " + mfd); System.out.print(", position : " + tiePosition + " tie"); System.out.print(", result : " + result); System.out.println(", expected : " + expectedOutput); } }
Example 19
Source File: TieRoundingTest.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
static void formatOutputTestDouble(NumberFormat nf, double doubleToTest, String tiePosition, String inputDigits, String expectedOutput) { int mfd = nf.getMaximumFractionDigits(); RoundingMode rm = nf.getRoundingMode(); String result = nf.format(doubleToTest); if (!result.equals(expectedOutput)) { System.out.println(); System.out.println("========================================"); System.out.println("***Failure : error formatting value from string : " + inputDigits); System.out.println("NumberFormat pattern is : " + ((DecimalFormat ) nf).toPattern()); System.out.println("Maximum number of fractional digits : " + mfd); System.out.println("Fractional rounding digit : " + (mfd + 1)); System.out.println("Position of value relative to tie : " + tiePosition); System.out.println("Rounding Mode : " + rm); System.out.println("BigDecimal output : " + new BigDecimal(doubleToTest).toString()); System.out.println("FloatingDecimal output : " + doubleToTest); System.out.println( "Error. Formatted result different from expected." + "\nExpected output is : \"" + expectedOutput + "\"" + "\nFormated output is : \"" + result + "\""); System.out.println("========================================"); System.out.println(); errorCounter++; allPassed = false; } else { testCounter++; System.out.println("\nSuccess for double value : " + doubleToTest + " :"); System.out.println(" Input digits :" + inputDigits + ", BigDecimal value : " + new BigDecimal(doubleToTest).toString()); System.out.print(" Rounding mode: " + rm); System.out.print(", fract digits : " + mfd); System.out.print(", position : " + tiePosition + " tie"); System.out.print(", result : " + result); System.out.println(", expected : " + expectedOutput); } }
Example 20
Source File: TieRoundingTest.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
static void formatOutputTestDouble(NumberFormat nf, double doubleToTest, String tiePosition, String inputDigits, String expectedOutput) { int mfd = nf.getMaximumFractionDigits(); RoundingMode rm = nf.getRoundingMode(); String result = nf.format(doubleToTest); if (!result.equals(expectedOutput)) { System.out.println(); System.out.println("========================================"); System.out.println("***Failure : error formatting value from string : " + inputDigits); System.out.println("NumberFormat pattern is : " + ((DecimalFormat ) nf).toPattern()); System.out.println("Maximum number of fractional digits : " + mfd); System.out.println("Fractional rounding digit : " + (mfd + 1)); System.out.println("Position of value relative to tie : " + tiePosition); System.out.println("Rounding Mode : " + rm); System.out.println("BigDecimal output : " + new BigDecimal(doubleToTest).toString()); System.out.println("FloatingDecimal output : " + doubleToTest); System.out.println( "Error. Formatted result different from expected." + "\nExpected output is : \"" + expectedOutput + "\"" + "\nFormated output is : \"" + result + "\""); System.out.println("========================================"); System.out.println(); errorCounter++; allPassed = false; } else { testCounter++; System.out.println("\nSuccess for double value : " + doubleToTest + " :"); System.out.println(" Input digits :" + inputDigits + ", BigDecimal value : " + new BigDecimal(doubleToTest).toString()); System.out.print(" Rounding mode: " + rm); System.out.print(", fract digits : " + mfd); System.out.print(", position : " + tiePosition + " tie"); System.out.print(", result : " + result); System.out.println(", expected : " + expectedOutput); } }