OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <cctype> | 10 #include <cctype> |
(...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
958 | 958 |
959 uint32_t CFX_ByteString::GetID(FX_STRSIZE start_pos) const { | 959 uint32_t CFX_ByteString::GetID(FX_STRSIZE start_pos) const { |
960 return AsStringC().GetID(start_pos); | 960 return AsStringC().GetID(start_pos); |
961 } | 961 } |
962 FX_STRSIZE FX_ftoa(FX_FLOAT d, FX_CHAR* buf) { | 962 FX_STRSIZE FX_ftoa(FX_FLOAT d, FX_CHAR* buf) { |
963 buf[0] = '0'; | 963 buf[0] = '0'; |
964 buf[1] = '\0'; | 964 buf[1] = '\0'; |
965 if (d == 0.0f) { | 965 if (d == 0.0f) { |
966 return 1; | 966 return 1; |
967 } | 967 } |
968 FX_BOOL bNegative = FALSE; | 968 bool bNegative = false; |
969 if (d < 0) { | 969 if (d < 0) { |
970 bNegative = TRUE; | 970 bNegative = true; |
971 d = -d; | 971 d = -d; |
972 } | 972 } |
973 int scale = 1; | 973 int scale = 1; |
974 int scaled = FXSYS_round(d); | 974 int scaled = FXSYS_round(d); |
975 while (scaled < 100000) { | 975 while (scaled < 100000) { |
976 if (scale == 1000000) { | 976 if (scale == 1000000) { |
977 break; | 977 break; |
978 } | 978 } |
979 scale *= 10; | 979 scale *= 10; |
980 scaled = FXSYS_round(d * scale); | 980 scaled = FXSYS_round(d * scale); |
(...skipping 22 matching lines...) Expand all Loading... |
1003 fraction %= scale; | 1003 fraction %= scale; |
1004 scale /= 10; | 1004 scale /= 10; |
1005 } | 1005 } |
1006 return buf_size; | 1006 return buf_size; |
1007 } | 1007 } |
1008 CFX_ByteString CFX_ByteString::FormatFloat(FX_FLOAT d, int precision) { | 1008 CFX_ByteString CFX_ByteString::FormatFloat(FX_FLOAT d, int precision) { |
1009 FX_CHAR buf[32]; | 1009 FX_CHAR buf[32]; |
1010 FX_STRSIZE len = FX_ftoa(d, buf); | 1010 FX_STRSIZE len = FX_ftoa(d, buf); |
1011 return CFX_ByteString(buf, len); | 1011 return CFX_ByteString(buf, len); |
1012 } | 1012 } |
OLD | NEW |