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

Unified Diff: src/double.h

Issue 4681001: Fix Double.NextDouble function. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 10 years, 1 month 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 | test/cctest/test-double.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/double.h
diff --git a/src/double.h b/src/double.h
index 9db8ea7c48b0339b5dab21a1a69cf991612b9efb..54b83ecd5daf0c7371976d14340d3821945ab7c5 100644
--- a/src/double.h
+++ b/src/double.h
@@ -83,8 +83,16 @@ class Double {
}
double NextDouble() const {
- if (d64_ == kInfinity) return kInfinity;
- return Double(d64_ + 1).value();
+ if (d64_ == kInfinity) return Double(kInfinity).value();
+ if (Sign() < 0 && Significand() == 0) {
+ // -0.0
+ return 0.0;
+ }
+ if (Sign() < 0) {
+ return Double(d64_ - 1).value();
+ } else {
+ return Double(d64_ + 1).value();
+ }
}
int Exponent() const {
« no previous file with comments | « no previous file | test/cctest/test-double.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698