Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Side by Side Diff: core/src/fxcrt/fx_basic_bstring.cpp

Issue 1258093002: FX Bool considered harmful, part 3 (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/src/fxcrt/fx_basic_array.cpp ('k') | core/src/fxcrt/fx_basic_buffer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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> // For offsetof(). 7 #include <stddef.h> // For offsetof().
8 8
9 #include "../../include/fxcrt/fx_basic.h" 9 #include "../../include/fxcrt/fx_basic.h"
10 #include "../../../third_party/base/numerics/safe_math.h" 10 #include "../../../third_party/base/numerics/safe_math.h"
(...skipping 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after
1079 } 1079 }
1080 return strid; 1080 return strid;
1081 } 1081 }
1082 FX_STRSIZE FX_ftoa(FX_FLOAT d, FX_CHAR* buf) 1082 FX_STRSIZE FX_ftoa(FX_FLOAT d, FX_CHAR* buf)
1083 { 1083 {
1084 buf[0] = '0'; 1084 buf[0] = '0';
1085 buf[1] = '\0'; 1085 buf[1] = '\0';
1086 if (d == 0.0f) { 1086 if (d == 0.0f) {
1087 return 1; 1087 return 1;
1088 } 1088 }
1089 FX_BOOL bNegative = FALSE; 1089 bool bNegative = false;
1090 if (d < 0) { 1090 if (d < 0) {
1091 bNegative = TRUE; 1091 bNegative = true;
1092 d = -d; 1092 d = -d;
1093 } 1093 }
1094 int scale = 1; 1094 int scale = 1;
1095 int scaled = FXSYS_round(d); 1095 int scaled = FXSYS_round(d);
1096 while (scaled < 100000) { 1096 while (scaled < 100000) {
1097 if (scale == 1000000) { 1097 if (scale == 1000000) {
1098 break; 1098 break;
1099 } 1099 }
1100 scale *= 10; 1100 scale *= 10;
1101 scaled = FXSYS_round(d * scale); 1101 scaled = FXSYS_round(d * scale);
(...skipping 23 matching lines...) Expand all
1125 scale /= 10; 1125 scale /= 10;
1126 } 1126 }
1127 return buf_size; 1127 return buf_size;
1128 } 1128 }
1129 CFX_ByteString CFX_ByteString::FormatFloat(FX_FLOAT d, int precision) 1129 CFX_ByteString CFX_ByteString::FormatFloat(FX_FLOAT d, int precision)
1130 { 1130 {
1131 FX_CHAR buf[32]; 1131 FX_CHAR buf[32];
1132 FX_STRSIZE len = FX_ftoa(d, buf); 1132 FX_STRSIZE len = FX_ftoa(d, buf);
1133 return CFX_ByteString(buf, len); 1133 return CFX_ByteString(buf, len);
1134 } 1134 }
OLDNEW
« no previous file with comments | « core/src/fxcrt/fx_basic_array.cpp ('k') | core/src/fxcrt/fx_basic_buffer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698