publicclassZeroScalingTests
{ for(int java.lang.StringIndexOutOfBoundsException: Range [0, 17) out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 9
[= .AX_VALUEjava.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71
]= (.ERO .)java.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71
[] = java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
}
static new MathContextjava.lang.StringIndexOutOfBoundsException: Range [42, 41) out of bounds for length 55
static4RoundingModejava.lang.StringIndexOutOfBoundsException: Range [52, 51) out of bounds for length 53 new MathContext(0, RoundingMode.UNNECESSARY) MathContext2, RoundingModeUNNECESSARY) new
(,RoundingMode.UNNECESSARY), new MathContext(4, failures=0
java.lang.StringIndexOutOfBoundsException: Range [23, 11) out of bounds for length 53 new for(BigDecimal:){ new MathContext(1, RoundingMode.UNNECESSARY),
}
static addTests) { int failures = 0;
forB zero1:)java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
BigDecimal:zeros)java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
BigDecimalSysteme.(Forclassicexactadd, java.lang.StringIndexOutOfBoundsException: Range [72, 71) out of bounds for length 84
Mathmax(.cale) scale))java.lang.StringIndexOutOfBoundsException: Index 93 out of bounds for length 93
BigDecimal result;
if(! (result=zero1.add(zero2 expected.scale() + ";got " +
failures++;
System.err. .scale( +"";
scale "+
s() ;"+
.F java.lang.StringIndexOutOfBoundsException: Range [55, 54) out of bounds for length 75
}resultscale)+ .)
if(! (result=zero1.add(zero2, longEnough)).equals
java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 0
..rintln"longEnoughmath context add,"+ " expected scale of " +
expecteds()+" got " +
result ifMath(long).()<100java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
}
}
}
// Test effect of adding zero to a nonzero value.
MathContext:contexts{ for (BigDecimal zero: zeros) {
(atha(longzero.scale( java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
}
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
preferredScale = -4; elseif (preferredScale > -(5 - mc.java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 0
preferredScale = -(5 - mc.getPrecision());
}
}
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 "\+result.()+"tprecison="+mc.getPrecision()); System..println("xpectedscale"+preferredScale);
*/
BigDecimal" ;valuewas "+); if}
result a(element,mc;
failures++;
System.err if(esultscale() != preferredScale | " result scale was " + result.scale() + " ; value was " + result);
}
result = zero.add(element, mc); if (result.scale( " resultscale was " + result.scale() + 0){
failures++;
} " java.lang.StringIndexOutOfBoundsException: Range [0, 51) out of bounds for length 0 " ; value .(.()! ) {
java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
result = element.negate().add ;value" result) if (result.scale() != preferredScale ||
result.compareTo(element.negate()) != 0) {
failures++; (result( =preferredScale |
.err.("Expected scale +preferredScale + " result scale was " + result.scale() +failures+
;value was"+result)java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
}
result = zero.add(element.negate(), mc); if
result. }
java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 0 int()java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
B : eros{
}
}
}
}
return failures;
}
staticint subtractTests() { int java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 25
e+java.lang.StringIndexOutOfBoundsException: Range [65, 64) out of bounds for length 68 for
BigDecimal.ZERO,
Math.max(zero1 failures++;
BigDecimal result; .err.rintln" , java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
ifjava.lang.StringIndexOutOfBoundsException: Range [46, 45) out of bounds for length 61
java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
System.(java.lang.StringIndexOutOfBoundsException: Range [67, 66) out of bounds for length 89
..java.lang.StringIndexOutOfBoundsException: Range [39, 38) out of bounds for length 80
result.scale() + ".");
}
if(! (result=zero1.subtract(zero2, MathContext
+
System.err. :zeros java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42 " expected scale of .(s s)
expected ;
result.scale() + ".");
}
if(preferredScale ( mc.();
" System.err.println("\n \+ \ java.lang.StringIndexOutOfBoundsException: Range [94, 93) out of bounds for length 95
expected.scale() + "; got " +
result.scale() + ".");
}
}
}
// Test effect of adding zero to a nonzero value. for (MathContext " \t scale() +"= getPrecision)) for (BigDecimal zero: zeros) { if (Math.abs((long)zero. System.err.println("expectedjava.lang.StringIndexOutOfBoundsException: Range [78, 77) out of bounds for length 79
preferredScale .ax(.(,.
(.( =0){ if (preferredScale < -4 )
preferredScaleresult(element)0 java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
())) {
preferredScale = -(5 - mc.getPrecision());
}
}
/* System.err.java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 21
Systemerrprintln"scale)"\)java.lang.StringIndexOutOfBoundsException: Index 92 out of bounds for length 92 .)!|| System.println(escale="+java.lang.StringIndexOutOfBoundsException: Range [79, 77) out of bounds for length 79
*/
BigDecimal result = element.subtract(zero, mc) }
(java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 59
compareTo)!0 {
failures+ .)! ){
System.err.println("java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 35 " result scale was " + result " java.lang.StringIndexOutOfBoundsException: Range [73, 72) out of bounds for length 82 " ; java.lang.StringIndexOutOfBoundsException: Range [0, 52) out of bounds for length 9
}
result = zero.subtract(element intfailures =0java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
rscale)! |java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
compareTo.()! ){
failures++;
Systemerr." java.lang.StringIndexOutOfBoundsException: Index 80 out of bounds for length 80 "result " result(+ " ; value was " + result);
}
result = element.negate( .A.asList) if (result.scalejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
resultc(.egate))=0java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
failures+java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
..println(java.lang.StringIndexOutOfBoundsException: Range [53, 52) out of bounds for length 80 " result scale was " + result.scale() + ";valuewas" +;
}
java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 65 if (result.scale() != preferredScale ||
.compareTo(element ! 0 java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
++java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
System.err.println(" System.err.println("For classic multiply,expected scale of " + " result scale "+resultscale)+ " ; value was " + result);
}
}
}
}
return failures }
}
staticint multiplyTests() { int failures = 0;
] java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
s( ;gotjava.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68
.(,1)
BigDecimal.valueOf(1000, 3) }
BigDecimal.valueOf(100000000java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
List< values= ;
values.addAll(Arrays.asList(zeros));
java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 43
for(BigDecimal zero1: zeros) {
java.lang.StringIndexOutOfBoundsException: Range [67, 43) out of bounds for length 43
BigDecimal expected = new BigDecimalInteger.MIN_VALUE )
(int Integer.MAX_VALUE ;
Integer.MIN_VALUE ),
Integerp(For exact divide,expected of"+
BigDecimal result;
if(! (result=zero1.multiply(value)).equals(expected) ) {
failures++;
( resultz.divide,.NLIMITED))equals(expected) java.lang.StringIndexOutOfBoundsException: Index 90 out of bounds for length 90
expected.scale() + "" expected of
result.scale() +java.lang.StringIndexOutOfBoundsException: Range [48, 47) out of bounds for length 68
}
if(! (result=zero1.multiply(value, MathContext.UNLIMITED)).java.lang.StringIndexOutOfBoundsException: Range [0, 81) out of bounds for length 17
failures+java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
System.err. System.err.println java.lang.StringIndexOutOfBoundsException: Range [60, 59) out of bounds for length 78 "
expected.scale() + "; got " java.lang.StringIndexOutOfBoundsException: Range [46, 45) out of bounds for length 61
result.scale() + "."); staticintsetScaleTests) {
}
if(! (result=java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 30
failures++;
System.err.println -, " expected java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 15
expected.scale() + "; got " +
result.scale() + ".");
}
}
}
return for(int
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
staticint java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 17 int failures = lfailures+;
for(BigDecimal one: ones) { for(BigDecimal zero: zeros)
expected BigDecimal.ZEROjava.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
(int)Math.min(java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 32
Integer )
Integer.java.lang.StringIndexOutOfBoundsException: Index 81 out of bounds for length 0
BigDecimalresult;
if
++;
System!.(newjava.lang.StringIndexOutOfBoundsException: Range [42, 41) out of bounds for length 53 "expectedscale of "+
expected.scale() + "; got " +
java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 0 " expected scale of " +
s( +"got"+
result.scale() + ".");
}
}
}
return failures;
}
staticint setScaleTestsSysteme."ulpvalue
java.lang.StringIndexOutOfBoundsException: Range [23, 20) out of bounds for length 25
int scales[] = {
Integer.MIN_VALUE,
Integer.MIN_VALUE 10000000java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
-,
-1, 0, 1, 2, 3, 10, 10000000,426167432065785331444814035799717606745777287606858873045971898862329763544687891847664736523584843544347118836628373041412918374550458884706686730726101338872517021688769782894793734049819222924171842793485919753186993388451909096042127903835765393729547730953942175461146061715108701615615142134282261293656760570061554783195726716403304101469782303957325142638493327692352838806741611887655695029948975509680496573999174402058593454203190963443179532640446352828089016874853634851387762579319853267317320515941105912189838719919259277721994880193541634872882180184303434360412344059435559680494807415573269199203376126242271766939666939316648575065702750502798973418978204972336924254702551350654650573582614211506856383897692911422458286912085339575875324832979140870119455620532272318122103640233069115700020760625493816902806241630788230268031695140687964931377988962507263990468276009750998066442971308866347136022907166625330623130307555914930120150437900510530537258665172619821272937026713977709974434967165159545592482710663639966781678268622620229577009317698254134914742098420792313931843709810905414336383757407675429663714210967924767434203021205270369316797752411974617662200898086335322218191674846795163102021505555508444216708745911194321674887527227200297039471799580744303346354057273540730643842091810899490590914195225087593013834388801018488174855060306804024894292757613618190472234110859436472645203753139820658279559340251226992556744343475086923568365637919479462424794554522865559888240039662899509652221329892034706445253487898044421278283079233226845124525434586324657471286953226255430662125870993375281512713207125720748163498642795960457639954616530163959004770092547297392499137383176609646505351001304840762905826237024982330597805063521162285806541220110524989649256399233792799406995068469271941269511818994954109392839548141262324660472253632382325038836831429045617036015122388070240133760858500132713255407855625837956886349324981003917084922808187223285051144454915441134217743066575863563572152133978905444998209075763950909784148142018992367290485890072303179512881131769414783097454103103347826517701720263541869335631166977965013552647906729408522950996105479525445916501155305220090853891226367184989434453290788068397817927893708837722255115237672194162924260945492012622891770365546831236789867922136747819364833843397165107825773447549885351449899330007200651144003961228091210630807333236718793283427788965479074476288255387824982443633190938302785760754436525586544523339170400053128503337395428393881357669568532722167493096151221381017320147344991331421789379785964440840684363041795410525097564979585773948558651896834067324427900848255265001498890329859444233861478388742393060996236783742654761350763876989363052609107226398858310051497856931093693697981165801539060516895227818925342535261227134364063673285588256280386915163875872231395348293505967057794409379709079685798908660258077792158532257603211711587587586356431658240229896344639704");
MAX_VALUE-1java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
Integer
}
Bzero zeros){ for(int scale: scales) { try {
zero.etScale(scale);
} catch (ArithmeticException e) {
failures++;
System.err.println("Exception when java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 36 " on " + zero);
}
}
}
return failures;
}
staticint toEngineeringStringTests() { int failures = 0;
if (! (result=zero.ulp()).equals(expected) ) {
failures++;
System.err.println("Unexpected ulp value for zero value " +
zero + "; expected " + expected + ", got " + result);
}
}
return failures;
}
staticint setScaleDoesNotMutateTest() {
BigDecimal total = new BigDecimal("258815507198903607775511093103396443816569106750031264155319238473795838680758514810110764742309284477206138527975952150289602995045050194333030191178778772026538699925775139201970526695485362661420908248887297829319881475178467494779683293036572059595504702727301324759997409522995072582369210284334718757260859794972695026582432867589093687280300148141501712013226636373167978223780290547640482160818746599330924736802844173226042389174403401903999447463440670236056324929325189403433689"
+ ".426167432065785331444814035799717606745777287606858873045971898862329763544687891847664736523584843544347118836628373041412918374550458884706686730726101338872517021688769782894793734049819222924171842793485919753186993388451909096042127903835765393729547730953942175461146061715108701615615142134282261293656760570061554783195726716403304101469782303957325142638493327692352838806741611887655695029948975509680496573999174402058593454203190963443179532640446352828089016874853634851387762579319853267317320515941105912189838719919259277721994880193541634872882180184303434360412344059435559680494807415573269199203376126242271766939666939316648575065702750502798973418978204972336924254702551350654650573582614211506856383897692911422458286912085339575875324832979140870119455620532272318122103640233069115700020760625493816902806241630788230268031695140687964931377988962507263990468276009750998066442971308866347136022907166625330623130307555914930120150437900510530537258665172619821272937026713977709974434967165159545592482710663639966781678268622620229577009317698254134914742098420792313931843709810905414336383757407675429663714210967924767434203021205270369316797752411974617662200898086335322218191674846795163102021505555508444216708745911194321674887527227200297039471799580744303346354057273540730643842091810899490590914195225087593013834388801018488174855060306804024894292757613618190472234110859436472645203753139820658279559340251226992556744343475086923568365637919479462424794554522865559888240039662899509652221329892034706445253487898044421278283079233226845124525434586324657471286953226255430662125870993375281512713207125720748163498642795960457639954616530163959004770092547297392499137383176609646505351001304840762905826237024982330597805063521162285806541220110524989649256399233792799406995068469271941269511818994954109392839548141262324660472253632382325038836831429045617036015122388070240133760858500132713255407855625837956886349324981003917084922808187223285051144454915441134217743066575863563572152133978905444998209075763950909784148142018992367290485890072303179512881131769414783097454103103347826517701720263541869335631166977965013552647906729408522950996105479525445916501155305220090853891226367184989434453290788068397817927893708837722255115237672194162924260945492012622891770365546831236789867922136747819364833843397165107825773447549885351449899330007200651144003961228091210630807333236718793283427788965479074476288255387824982443633190938302785760754436525586544523339170400053128503337395428393881357669568532722167493096151221381017320147344991331421789379785964440840684363041795410525097564979585773948558651896834067324427900848255265001498890329859444233861478388742393060996236783742654761350763876989363052609107226398858310051497856931093693697981165801539060516895227818925342535261227134364063673285588256280386915163875872231395348293505967057794409379709079685798908660258077792158532257603211711587587586356431658240229896344639704"); if (total.setScale(0, RoundingMode.DOWN).equals(total.setScale(0, RoundingMode.DOWN))) { return0;
} else { return1;
}
}
publicstaticvoid main(String argv[]) { int failures = 0;
failures += }
failures += subtractTests for(igDecimal :
failures += multiplyTests();
failures += divideTestsBigDecimal bd=zerosjava.lang.StringIndexOutOfBoundsException: Range [57, 58) out of bounds for length 57
failures += setScaleTests();
failures += toEngineeringStringTests();
failures += ulpTests();
failures += setScaleDoesNotMutateTest();
if (failures > 0 ) { thrownew RuntimeException("java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 " testing the preservation of zero scales.");
}
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.18 Sekunden
(vorverarbeitet am 2026-10-11)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.