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

Side by Side Diff: src/double.h

Issue 866002: Fast double-to-ascii conversion. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « src/diy_fp.h ('k') | src/globals.h » ('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 28 matching lines...) Expand all
39 39
40 // Helper functions for doubles. 40 // Helper functions for doubles.
41 class Double { 41 class Double {
42 public: 42 public:
43 static const uint64_t kSignMask = V8_2PART_UINT64_C(0x80000000, 00000000); 43 static const uint64_t kSignMask = V8_2PART_UINT64_C(0x80000000, 00000000);
44 static const uint64_t kExponentMask = V8_2PART_UINT64_C(0x7FF00000, 00000000); 44 static const uint64_t kExponentMask = V8_2PART_UINT64_C(0x7FF00000, 00000000);
45 static const uint64_t kSignificandMask = 45 static const uint64_t kSignificandMask =
46 V8_2PART_UINT64_C(0x000FFFFF, FFFFFFFF); 46 V8_2PART_UINT64_C(0x000FFFFF, FFFFFFFF);
47 static const uint64_t kHiddenBit = V8_2PART_UINT64_C(0x00100000, 00000000); 47 static const uint64_t kHiddenBit = V8_2PART_UINT64_C(0x00100000, 00000000);
48 48
49 Double() : d64_(0.0) {} 49 Double() : d64_(0) {}
50 explicit Double(double d) : d64_(double_to_uint64(d)) {} 50 explicit Double(double d) : d64_(double_to_uint64(d)) {}
51 explicit Double(uint64_t d64) : d64_(d64) {} 51 explicit Double(uint64_t d64) : d64_(d64) {}
52 52
53 DiyFp AsDiyFp() const { 53 DiyFp AsDiyFp() const {
54 ASSERT(!IsSpecial()); 54 ASSERT(!IsSpecial());
55 return DiyFp(Significand(), Exponent()); 55 return DiyFp(Significand(), Exponent());
56 } 56 }
57 57
58 // this->Significand() must not be 0. 58 // this->Significand() must not be 0.
59 DiyFp AsNormalizedDiyFp() const { 59 DiyFp AsNormalizedDiyFp() const {
(...skipping 15 matching lines...) Expand all
75 75
76 // Returns the double's bit as uint64. 76 // Returns the double's bit as uint64.
77 uint64_t AsUint64() const { 77 uint64_t AsUint64() const {
78 return d64_; 78 return d64_;
79 } 79 }
80 80
81 int Exponent() const { 81 int Exponent() const {
82 if (IsDenormal()) return kDenormalExponent; 82 if (IsDenormal()) return kDenormalExponent;
83 83
84 uint64_t d64 = AsUint64(); 84 uint64_t d64 = AsUint64();
85 int biased_e = (d64 & kExponentMask) >> kSignificandSize; 85 int biased_e = static_cast<int>((d64 & kExponentMask) >> kSignificandSize);
86 return biased_e - kExponentBias; 86 return biased_e - kExponentBias;
87 } 87 }
88 88
89 uint64_t Significand() const { 89 uint64_t Significand() const {
90 uint64_t d64 = AsUint64(); 90 uint64_t d64 = AsUint64();
91 uint64_t significand = d64 & kSignificandMask; 91 uint64_t significand = d64 & kSignificandMask;
92 if (!IsDenormal()) { 92 if (!IsDenormal()) {
93 return significand + kHiddenBit; 93 return significand + kHiddenBit;
94 } else { 94 } else {
95 return significand; 95 return significand;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 static const int kSignificandSize = 52; // Excludes the hidden bit. 160 static const int kSignificandSize = 52; // Excludes the hidden bit.
161 static const int kExponentBias = 0x3FF + kSignificandSize; 161 static const int kExponentBias = 0x3FF + kSignificandSize;
162 static const int kDenormalExponent = -kExponentBias + 1; 162 static const int kDenormalExponent = -kExponentBias + 1;
163 163
164 uint64_t d64_; 164 uint64_t d64_;
165 }; 165 };
166 166
167 } } // namespace v8::internal 167 } } // namespace v8::internal
168 168
169 #endif // V8_DOUBLE_H_ 169 #endif // V8_DOUBLE_H_
OLDNEW
« no previous file with comments | « src/diy_fp.h ('k') | src/globals.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698