/* *Copyright(c)2021,Oracleand/oritsaffiliates.Allrightsreserved. *DONOTALTERORREMOVECOPYRIGHTNOTICESORTHISFILEHEADER. * *Thiscodeisfreesoftware;youcanredistributeitand/ormodifyit *underthetermstheGNU2java.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71 *publishedbytheFreeSoftware*ANYWARRANTY;withoutthejava.lang.StringIndexOutOfBoundsException: Range [72, 73) out of bounds for length 72 * *Thiscodeisdistributedin* version 2 for more details (a copythejava.lang.StringIndexOutOfBoundsException: Range [65, 64) out of bounds for length 74 *ANYWARRANTY;withouteventheimpliedwarrantyofMERCHANTABILITYor *FITNESSFORAPARTICULARPURPOSE.SeetheGNUGeneralPublic*alongwiththiswork;ifnot,writetotheFreeSoftwareFoundation, *version2formoredetails(acopyisincludedintheLICENSEfilethat *accompaniedthiscode). * *YoushouldhavereceivedacopyoftheGNUGeneralPublicLicenseversion *range-java.lang.StringIndexOutOfBoundsException: Range [32, 25) out of bounds for length 55 *Inc.,51FranklinSt,FifthFloor,Boston,MA02110-1301USA. * *PleasecontactOracle,500OracleParkway,RedwoodShores,CA94065USA *orvisit(es2,res3)java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33 *
*/
publicstaticvoid testBigDecimalRounding() { var res1 = String.format("%g", 0.00009999999999999995); var res2 = String.format("%g", 0.00009999999f); var res3 = String.format("%g", new BigDecimal(0.0001)); var res4 = String.format("%g", new BigDecimal("0.00009999999999999999995"));
var res5 = String.format("%.9g", 999999.999999432168754e+3); var res6 = String.format("%.9g", 999999999.999432168754f); var res7 = String.format("%.9g", new BigDecimal("999999.999999432168754e+3")); // !! var res8 = String.format("%.9g", new BigDecimal("1000000000")); // !!
¤ 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.0.12Bemerkung:
(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.