11/*
2- * Copyright (c) 2003, 2023 , Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2003, 2024 , Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * This code is free software; you can redistribute it and/or modify it
@@ -885,13 +885,10 @@ public AbstractStringBuilder append(long l) {
885885 * @return a reference to this object.
886886 */
887887 public AbstractStringBuilder append (float f ) {
888- try {
889- FloatToDecimal .appendTo (f , this );
890- } catch (IOException e ) {
891- throw new AssertionError (e );
892- }
888+ ensureCapacityInternal (count + FloatToDecimal .MAX_CHARS );
889+ FloatToDecimal toDecimal = isLatin1 () ? FloatToDecimal .LATIN1 : FloatToDecimal .UTF16 ;
890+ count = toDecimal .putDecimal (value , count , f );
893891 return this ;
894-
895892 }
896893
897894 /**
@@ -907,11 +904,9 @@ public AbstractStringBuilder append(float f) {
907904 * @return a reference to this object.
908905 */
909906 public AbstractStringBuilder append (double d ) {
910- try {
911- DoubleToDecimal .appendTo (d , this );
912- } catch (IOException e ) {
913- throw new AssertionError (e );
914- }
907+ ensureCapacityInternal (count + DoubleToDecimal .MAX_CHARS );
908+ DoubleToDecimal toDecimal = isLatin1 () ? DoubleToDecimal .LATIN1 : DoubleToDecimal .UTF16 ;
909+ count = toDecimal .putDecimal (value , count , d );
915910 return this ;
916911 }
917912
0 commit comments