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

Unified Diff: runtime/lib/double.cc

Issue 9113043: Implement Double.{toString, toStringAsExponential, toStringAsPrecision} (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/lib/double.dart » ('j') | runtime/vm/double_conversion.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/double.cc
diff --git a/runtime/lib/double.cc b/runtime/lib/double.cc
index 00c68e823af1033d676c8ada5744f8cd8eaa93b8..5cec30b556a258a1057b2fb21c0c9d20101cda12 100644
--- a/runtime/lib/double.cc
+++ b/runtime/lib/double.cc
@@ -203,12 +203,37 @@ DEFINE_NATIVE_ENTRY(Double_toStringAsFixed, 2) {
DEFINE_NATIVE_ENTRY(Double_toStringAsExponential, 2) {
- UNIMPLEMENTED();
+ const Double& arg = Double::CheckedHandle(arguments->At(0));
+ GET_NATIVE_ARGUMENT(Smi, fraction_digits, arguments->At(1));
+ double d = arg.value();
+ int fraction_digits_value = fraction_digits.Value();
+ String& result = String::Handle();
+ bool succeeded =
+ DoubleToStringAsExponential(d, fraction_digits_value, result);
+ if (!succeeded) {
+ GrowableArray<const Object*> args;
+ args.Add(&String::ZoneHandle(String::New(
+ "Illegal arguments to double.toStringAsExponential")));
+ Exceptions::ThrowByType(Exceptions::kIllegalArgument, args);
+ }
+ arguments->SetReturn(result);
}
DEFINE_NATIVE_ENTRY(Double_toStringAsPrecision, 2) {
- UNIMPLEMENTED();
+ const Double& arg = Double::CheckedHandle(arguments->At(0));
+ GET_NATIVE_ARGUMENT(Smi, precision, arguments->At(1));
+ double d = arg.value();
+ int precision_value = precision.Value();
+ String& result = String::Handle();
+ bool succeeded = DoubleToStringAsPrecision(d, precision_value, result);
+ if (!succeeded) {
+ GrowableArray<const Object*> args;
+ args.Add(&String::ZoneHandle(String::New(
+ "Illegal arguments to double.toStringAsPrecision")));
+ Exceptions::ThrowByType(Exceptions::kIllegalArgument, args);
+ }
+ arguments->SetReturn(result);
}
« no previous file with comments | « no previous file | runtime/lib/double.dart » ('j') | runtime/vm/double_conversion.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698