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

Side by Side Diff: src/double.h

Issue 4060001: Bignum implementation of Strtod. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: bignum.h changes that somehow disappeared earlier. 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/bignum.cc ('k') | src/strtod.cc » ('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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 f <<= DiyFp::kSignificandSize - kSignificandSize; 75 f <<= DiyFp::kSignificandSize - kSignificandSize;
76 e -= DiyFp::kSignificandSize - kSignificandSize; 76 e -= DiyFp::kSignificandSize - kSignificandSize;
77 return DiyFp(f, e); 77 return DiyFp(f, e);
78 } 78 }
79 79
80 // Returns the double's bit as uint64. 80 // Returns the double's bit as uint64.
81 uint64_t AsUint64() const { 81 uint64_t AsUint64() const {
82 return d64_; 82 return d64_;
83 } 83 }
84 84
85 double NextDouble() const {
86 if (d64_ == kInfinity) return kInfinity;
87 return Double(d64_ + 1).value();
88 }
89
85 int Exponent() const { 90 int Exponent() const {
86 if (IsDenormal()) return kDenormalExponent; 91 if (IsDenormal()) return kDenormalExponent;
87 92
88 uint64_t d64 = AsUint64(); 93 uint64_t d64 = AsUint64();
89 int biased_e = 94 int biased_e =
90 static_cast<int>((d64 & kExponentMask) >> kPhysicalSignificandSize); 95 static_cast<int>((d64 & kExponentMask) >> kPhysicalSignificandSize);
91 return biased_e - kExponentBias; 96 return biased_e - kExponentBias;
92 } 97 }
93 98
94 uint64_t Significand() const { 99 uint64_t Significand() const {
(...skipping 18 matching lines...) Expand all
113 uint64_t d64 = AsUint64(); 118 uint64_t d64 = AsUint64();
114 return (d64 & kExponentMask) == kExponentMask; 119 return (d64 & kExponentMask) == kExponentMask;
115 } 120 }
116 121
117 bool IsNan() const { 122 bool IsNan() const {
118 uint64_t d64 = AsUint64(); 123 uint64_t d64 = AsUint64();
119 return ((d64 & kExponentMask) == kExponentMask) && 124 return ((d64 & kExponentMask) == kExponentMask) &&
120 ((d64 & kSignificandMask) != 0); 125 ((d64 & kSignificandMask) != 0);
121 } 126 }
122 127
123
124 bool IsInfinite() const { 128 bool IsInfinite() const {
125 uint64_t d64 = AsUint64(); 129 uint64_t d64 = AsUint64();
126 return ((d64 & kExponentMask) == kExponentMask) && 130 return ((d64 & kExponentMask) == kExponentMask) &&
127 ((d64 & kSignificandMask) == 0); 131 ((d64 & kSignificandMask) == 0);
128 } 132 }
129 133
130
131 int Sign() const { 134 int Sign() const {
132 uint64_t d64 = AsUint64(); 135 uint64_t d64 = AsUint64();
133 return (d64 & kSignMask) == 0? 1: -1; 136 return (d64 & kSignMask) == 0? 1: -1;
134 } 137 }
135 138
139 DiyFp UpperBoundary() const {
140 return DiyFp(Significand() * 2 + 1, Exponent() - 1);
141 }
136 142
137 // Returns the two boundaries of this. 143 // Returns the two boundaries of this.
138 // The bigger boundary (m_plus) is normalized. The lower boundary has the same 144 // The bigger boundary (m_plus) is normalized. The lower boundary has the same
139 // exponent as m_plus. 145 // exponent as m_plus.
140 void NormalizedBoundaries(DiyFp* out_m_minus, DiyFp* out_m_plus) const { 146 void NormalizedBoundaries(DiyFp* out_m_minus, DiyFp* out_m_plus) const {
141 DiyFp v = this->AsDiyFp(); 147 DiyFp v = this->AsDiyFp();
142 bool significand_is_zero = (v.f() == kHiddenBit); 148 bool significand_is_zero = (v.f() == kHiddenBit);
143 DiyFp m_plus = DiyFp::Normalize(DiyFp((v.f() << 1) + 1, v.e() - 1)); 149 DiyFp m_plus = DiyFp::Normalize(DiyFp((v.f() << 1) + 1, v.e() - 1));
144 DiyFp m_minus; 150 DiyFp m_minus;
145 if (significand_is_zero && v.e() != kDenormalExponent) { 151 if (significand_is_zero && v.e() != kDenormalExponent) {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 biased_exponent = static_cast<uint64_t>(exponent + kExponentBias); 213 biased_exponent = static_cast<uint64_t>(exponent + kExponentBias);
208 } 214 }
209 return (significand & kSignificandMask) | 215 return (significand & kSignificandMask) |
210 (biased_exponent << kPhysicalSignificandSize); 216 (biased_exponent << kPhysicalSignificandSize);
211 } 217 }
212 }; 218 };
213 219
214 } } // namespace v8::internal 220 } } // namespace v8::internal
215 221
216 #endif // V8_DOUBLE_H_ 222 #endif // V8_DOUBLE_H_
OLDNEW
« no previous file with comments | « src/bignum.cc ('k') | src/strtod.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698