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

Side by Side Diff: runtime/vm/double_internals.h

Issue 2481873005: clang-format runtime/vm (Closed)
Patch Set: Merge Created 4 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
« no previous file with comments | « runtime/vm/double_conversion.cc ('k') | runtime/vm/exceptions.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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef RUNTIME_VM_DOUBLE_INTERNALS_H_ 5 #ifndef RUNTIME_VM_DOUBLE_INTERNALS_H_
6 #define RUNTIME_VM_DOUBLE_INTERNALS_H_ 6 #define RUNTIME_VM_DOUBLE_INTERNALS_H_
7 7
8 #include "platform/utils.h" 8 #include "platform/utils.h"
9 9
10 namespace dart { 10 namespace dart {
11 11
12 // We assume that doubles and uint64_t have the same endianness. 12 // We assume that doubles and uint64_t have the same endianness.
13 static uint64_t double_to_uint64(double d) { return bit_cast<uint64_t>(d); } 13 static uint64_t double_to_uint64(double d) {
14 return bit_cast<uint64_t>(d);
15 }
14 16
15 // Helper functions for doubles. 17 // Helper functions for doubles.
16 class DoubleInternals { 18 class DoubleInternals {
17 public: 19 public:
18 static const int kSignificandSize = 53; 20 static const int kSignificandSize = 53;
19 21
20 explicit DoubleInternals(double d) : d64_(double_to_uint64(d)) {} 22 explicit DoubleInternals(double d) : d64_(double_to_uint64(d)) {}
21 23
22 // Returns the double's bit as uint64. 24 // Returns the double's bit as uint64.
23 uint64_t AsUint64() const { 25 uint64_t AsUint64() const { return d64_; }
24 return d64_;
25 }
26 26
27 int Exponent() const { 27 int Exponent() const {
28 if (IsDenormal()) return kDenormalExponent; 28 if (IsDenormal()) return kDenormalExponent;
29 29
30 uint64_t d64 = AsUint64(); 30 uint64_t d64 = AsUint64();
31 int biased_e = 31 int biased_e =
32 static_cast<int>((d64 & kExponentMask) >> kPhysicalSignificandSize); 32 static_cast<int>((d64 & kExponentMask) >> kPhysicalSignificandSize);
33 return biased_e - kExponentBias; 33 return biased_e - kExponentBias;
34 } 34 }
35 35
(...skipping 15 matching lines...) Expand all
51 51
52 // We consider denormals not to be special. 52 // We consider denormals not to be special.
53 // Hence only Infinity and NaN are special. 53 // Hence only Infinity and NaN are special.
54 bool IsSpecial() const { 54 bool IsSpecial() const {
55 uint64_t d64 = AsUint64(); 55 uint64_t d64 = AsUint64();
56 return (d64 & kExponentMask) == kExponentMask; 56 return (d64 & kExponentMask) == kExponentMask;
57 } 57 }
58 58
59 int Sign() const { 59 int Sign() const {
60 uint64_t d64 = AsUint64(); 60 uint64_t d64 = AsUint64();
61 return (d64 & kSignMask) == 0? 1: -1; 61 return (d64 & kSignMask) == 0 ? 1 : -1;
62 } 62 }
63 63
64 private: 64 private:
65 static const uint64_t kSignMask = DART_2PART_UINT64_C(0x80000000, 00000000); 65 static const uint64_t kSignMask = DART_2PART_UINT64_C(0x80000000, 00000000);
66 static const uint64_t kExponentMask = 66 static const uint64_t kExponentMask =
67 DART_2PART_UINT64_C(0x7FF00000, 00000000); 67 DART_2PART_UINT64_C(0x7FF00000, 00000000);
68 static const uint64_t kSignificandMask = 68 static const uint64_t kSignificandMask =
69 DART_2PART_UINT64_C(0x000FFFFF, FFFFFFFF); 69 DART_2PART_UINT64_C(0x000FFFFF, FFFFFFFF);
70 static const uint64_t kHiddenBit = DART_2PART_UINT64_C(0x00100000, 00000000); 70 static const uint64_t kHiddenBit = DART_2PART_UINT64_C(0x00100000, 00000000);
71 static const int kPhysicalSignificandSize = 52; // Excludes the hidden bit. 71 static const int kPhysicalSignificandSize = 52; // Excludes the hidden bit.
72 static const int kExponentBias = 0x3FF + kPhysicalSignificandSize; 72 static const int kExponentBias = 0x3FF + kPhysicalSignificandSize;
73 static const int kDenormalExponent = -kExponentBias + 1; 73 static const int kDenormalExponent = -kExponentBias + 1;
74 74
75 const uint64_t d64_; 75 const uint64_t d64_;
76 }; 76 };
77 77
78 } // namespace dart 78 } // namespace dart
79 79
80 #endif // RUNTIME_VM_DOUBLE_INTERNALS_H_ 80 #endif // RUNTIME_VM_DOUBLE_INTERNALS_H_
OLDNEW
« no previous file with comments | « runtime/vm/double_conversion.cc ('k') | runtime/vm/exceptions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698