1
1
/*
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.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
@@ -885,13 +885,10 @@ public AbstractStringBuilder append(long l) {
885
885
* @return a reference to this object.
886
886
*/
887
887
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 );
893
891
return this ;
894
-
895
892
}
896
893
897
894
/**
@@ -907,11 +904,9 @@ public AbstractStringBuilder append(float f) {
907
904
* @return a reference to this object.
908
905
*/
909
906
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 );
915
910
return this ;
916
911
}
917
912
0 commit comments