Chromium Code Reviews| Index: runtime/vm/object.cc |
| =================================================================== |
| --- runtime/vm/object.cc (revision 1359) |
| +++ runtime/vm/object.cc (working copy) |
| @@ -5262,6 +5262,15 @@ |
| char* chars = reinterpret_cast<char*>( |
| Isolate::Current()->current_zone()->Allocate(len)); |
| OS::SNPrint(chars, len, kFormat, value()); |
| + // Eliminate trailing 0s, but leave one digit after '.'. |
|
hausner
2011/11/09 19:32:01
Doesn't the %f format specifier suppress trailing
srdjan
2011/11/09 21:48:55
Unfortunately it doesn't.
|
| + // 'chars' is null terminated. |
| + for (intptr_t i = len - 2; i >= 1; i--) { |
| + if ((chars[i] == '0') && (chars[i - 1] != '.')) { |
| + chars[i] = '\0'; |
| + } else { |
| + break; |
| + } |
| + } |
| return chars; |
| } |