quickfix_ruby_ud 2.0.7-aarch64-linux
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/ext/quickfix/Acceptor.cpp +257 -0
- data/ext/quickfix/Acceptor.h +127 -0
- data/ext/quickfix/Allocator.h +9 -0
- data/ext/quickfix/Application.h +137 -0
- data/ext/quickfix/DOMDocument.h +70 -0
- data/ext/quickfix/DataDictionary.cpp +679 -0
- data/ext/quickfix/DataDictionary.h +607 -0
- data/ext/quickfix/DataDictionaryProvider.cpp +66 -0
- data/ext/quickfix/DataDictionaryProvider.h +67 -0
- data/ext/quickfix/DatabaseConnectionID.h +98 -0
- data/ext/quickfix/DatabaseConnectionPool.h +84 -0
- data/ext/quickfix/Dictionary.cpp +157 -0
- data/ext/quickfix/Dictionary.h +89 -0
- data/ext/quickfix/Event.h +89 -0
- data/ext/quickfix/Except.h +39 -0
- data/ext/quickfix/Exceptions.h +257 -0
- data/ext/quickfix/Field.h +654 -0
- data/ext/quickfix/FieldConvertors.cpp +86 -0
- data/ext/quickfix/FieldConvertors.h +800 -0
- data/ext/quickfix/FieldMap.cpp +254 -0
- data/ext/quickfix/FieldMap.h +327 -0
- data/ext/quickfix/FieldNumbers.h +44 -0
- data/ext/quickfix/FieldTypes.cpp +62 -0
- data/ext/quickfix/FieldTypes.h +817 -0
- data/ext/quickfix/Fields.h +30 -0
- data/ext/quickfix/FileLog.cpp +176 -0
- data/ext/quickfix/FileLog.h +110 -0
- data/ext/quickfix/FileStore.cpp +369 -0
- data/ext/quickfix/FileStore.h +131 -0
- data/ext/quickfix/FixCommonFields.h +13 -0
- data/ext/quickfix/FixFieldNumbers.h +6132 -0
- data/ext/quickfix/FixFields.h +6133 -0
- data/ext/quickfix/FixValues.h +5790 -0
- data/ext/quickfix/Group.cpp +44 -0
- data/ext/quickfix/Group.h +78 -0
- data/ext/quickfix/HostDetailsProvider.cpp +79 -0
- data/ext/quickfix/HostDetailsProvider.h +44 -0
- data/ext/quickfix/HtmlBuilder.h +178 -0
- data/ext/quickfix/HttpConnection.cpp +914 -0
- data/ext/quickfix/HttpConnection.h +74 -0
- data/ext/quickfix/HttpMessage.cpp +229 -0
- data/ext/quickfix/HttpMessage.h +112 -0
- data/ext/quickfix/HttpParser.cpp +49 -0
- data/ext/quickfix/HttpParser.h +49 -0
- data/ext/quickfix/HttpServer.cpp +152 -0
- data/ext/quickfix/HttpServer.h +76 -0
- data/ext/quickfix/Initiator.cpp +310 -0
- data/ext/quickfix/Initiator.h +151 -0
- data/ext/quickfix/Log.cpp +71 -0
- data/ext/quickfix/Log.h +254 -0
- data/ext/quickfix/Message.cpp +617 -0
- data/ext/quickfix/Message.h +419 -0
- data/ext/quickfix/MessageCracker.h +171 -0
- data/ext/quickfix/MessageSorters.cpp +101 -0
- data/ext/quickfix/MessageSorters.h +185 -0
- data/ext/quickfix/MessageStore.cpp +182 -0
- data/ext/quickfix/MessageStore.h +164 -0
- data/ext/quickfix/Mutex.h +120 -0
- data/ext/quickfix/MySQLConnection.h +187 -0
- data/ext/quickfix/MySQLLog.cpp +262 -0
- data/ext/quickfix/MySQLLog.h +158 -0
- data/ext/quickfix/MySQLStore.cpp +323 -0
- data/ext/quickfix/MySQLStore.h +161 -0
- data/ext/quickfix/MySQLStubs.h +203 -0
- data/ext/quickfix/NullStore.cpp +40 -0
- data/ext/quickfix/NullStore.h +89 -0
- data/ext/quickfix/OdbcConnection.h +241 -0
- data/ext/quickfix/OdbcLog.cpp +230 -0
- data/ext/quickfix/OdbcLog.h +109 -0
- data/ext/quickfix/OdbcStore.cpp +313 -0
- data/ext/quickfix/OdbcStore.h +124 -0
- data/ext/quickfix/PUGIXML_DOMDocument.cpp +112 -0
- data/ext/quickfix/PUGIXML_DOMDocument.h +81 -0
- data/ext/quickfix/Parser.cpp +111 -0
- data/ext/quickfix/Parser.h +50 -0
- data/ext/quickfix/PostgreSQLConnection.h +163 -0
- data/ext/quickfix/PostgreSQLLog.cpp +263 -0
- data/ext/quickfix/PostgreSQLLog.h +157 -0
- data/ext/quickfix/PostgreSQLStore.cpp +327 -0
- data/ext/quickfix/PostgreSQLStore.h +160 -0
- data/ext/quickfix/PostgreSQLStubs.h +203 -0
- data/ext/quickfix/Queue.h +66 -0
- data/ext/quickfix/QuickfixRuby.cpp +131900 -0
- data/ext/quickfix/QuickfixRuby.h +56 -0
- data/ext/quickfix/Responder.h +41 -0
- data/ext/quickfix/SSLSocketAcceptor.cpp +409 -0
- data/ext/quickfix/SSLSocketAcceptor.h +186 -0
- data/ext/quickfix/SSLSocketConnection.cpp +434 -0
- data/ext/quickfix/SSLSocketConnection.h +221 -0
- data/ext/quickfix/SSLSocketInitiator.cpp +558 -0
- data/ext/quickfix/SSLSocketInitiator.h +203 -0
- data/ext/quickfix/SSLStubs.h +129 -0
- data/ext/quickfix/Session.cpp +1437 -0
- data/ext/quickfix/Session.h +343 -0
- data/ext/quickfix/SessionFactory.cpp +314 -0
- data/ext/quickfix/SessionFactory.h +84 -0
- data/ext/quickfix/SessionID.h +136 -0
- data/ext/quickfix/SessionSettings.cpp +165 -0
- data/ext/quickfix/SessionSettings.h +283 -0
- data/ext/quickfix/SessionState.h +260 -0
- data/ext/quickfix/Settings.cpp +160 -0
- data/ext/quickfix/Settings.h +56 -0
- data/ext/quickfix/SharedArray.h +274 -0
- data/ext/quickfix/SocketAcceptor.cpp +216 -0
- data/ext/quickfix/SocketAcceptor.h +77 -0
- data/ext/quickfix/SocketConnection.cpp +256 -0
- data/ext/quickfix/SocketConnection.h +102 -0
- data/ext/quickfix/SocketConnector.cpp +112 -0
- data/ext/quickfix/SocketConnector.h +76 -0
- data/ext/quickfix/SocketInitiator.cpp +241 -0
- data/ext/quickfix/SocketInitiator.h +76 -0
- data/ext/quickfix/SocketMonitor.h +26 -0
- data/ext/quickfix/SocketMonitor_UNIX.cpp +238 -0
- data/ext/quickfix/SocketMonitor_UNIX.h +101 -0
- data/ext/quickfix/SocketMonitor_WIN32.cpp +248 -0
- data/ext/quickfix/SocketMonitor_WIN32.h +99 -0
- data/ext/quickfix/SocketServer.cpp +163 -0
- data/ext/quickfix/SocketServer.h +100 -0
- data/ext/quickfix/ThreadedSSLSocketAcceptor.cpp +436 -0
- data/ext/quickfix/ThreadedSSLSocketAcceptor.h +209 -0
- data/ext/quickfix/ThreadedSSLSocketConnection.cpp +364 -0
- data/ext/quickfix/ThreadedSSLSocketConnection.h +191 -0
- data/ext/quickfix/ThreadedSSLSocketInitiator.cpp +434 -0
- data/ext/quickfix/ThreadedSSLSocketInitiator.h +193 -0
- data/ext/quickfix/ThreadedSocketAcceptor.cpp +242 -0
- data/ext/quickfix/ThreadedSocketAcceptor.h +95 -0
- data/ext/quickfix/ThreadedSocketConnection.cpp +227 -0
- data/ext/quickfix/ThreadedSocketConnection.h +89 -0
- data/ext/quickfix/ThreadedSocketInitiator.cpp +238 -0
- data/ext/quickfix/ThreadedSocketInitiator.h +78 -0
- data/ext/quickfix/TimeRange.cpp +227 -0
- data/ext/quickfix/TimeRange.h +215 -0
- data/ext/quickfix/Utility.cpp +639 -0
- data/ext/quickfix/Utility.h +255 -0
- data/ext/quickfix/UtilitySSL.cpp +1612 -0
- data/ext/quickfix/UtilitySSL.h +274 -0
- data/ext/quickfix/Values.h +63 -0
- data/ext/quickfix/config-all.h +10 -0
- data/ext/quickfix/config.h +10 -0
- data/ext/quickfix/config_unix.h +178 -0
- data/ext/quickfix/config_windows.h +0 -0
- data/ext/quickfix/dirent_windows.h +838 -0
- data/ext/quickfix/double-conversion/bignum-dtoa.cc +641 -0
- data/ext/quickfix/double-conversion/bignum-dtoa.h +84 -0
- data/ext/quickfix/double-conversion/bignum.cc +766 -0
- data/ext/quickfix/double-conversion/bignum.h +144 -0
- data/ext/quickfix/double-conversion/cached-powers.cc +176 -0
- data/ext/quickfix/double-conversion/cached-powers.h +64 -0
- data/ext/quickfix/double-conversion/diy-fp.cc +57 -0
- data/ext/quickfix/double-conversion/diy-fp.h +118 -0
- data/ext/quickfix/double-conversion/double-conversion.cc +994 -0
- data/ext/quickfix/double-conversion/double-conversion.h +543 -0
- data/ext/quickfix/double-conversion/fast-dtoa.cc +665 -0
- data/ext/quickfix/double-conversion/fast-dtoa.h +88 -0
- data/ext/quickfix/double-conversion/fixed-dtoa.cc +404 -0
- data/ext/quickfix/double-conversion/fixed-dtoa.h +56 -0
- data/ext/quickfix/double-conversion/ieee.h +402 -0
- data/ext/quickfix/double-conversion/strtod.cc +557 -0
- data/ext/quickfix/double-conversion/strtod.h +45 -0
- data/ext/quickfix/double-conversion/utils.h +374 -0
- data/ext/quickfix/extconf.rb +76 -0
- data/ext/quickfix/index.h +37 -0
- data/ext/quickfix/pugiconfig.hpp +77 -0
- data/ext/quickfix/pugixml.cpp +13237 -0
- data/ext/quickfix/pugixml.hpp +1516 -0
- data/ext/quickfix/scope_guard.hpp +215 -0
- data/ext/quickfix/stdint_msvc.h +254 -0
- data/ext/quickfix/strptime.h +7 -0
- data/lib/2.4/quickfix.so +0 -0
- data/lib/2.5/quickfix.so +0 -0
- data/lib/2.6/quickfix.so +0 -0
- data/lib/2.7/quickfix.so +0 -0
- data/lib/3.0/quickfix.so +0 -0
- data/lib/3.1/quickfix.so +0 -0
- data/lib/3.2/quickfix.so +0 -0
- data/lib/3.3/quickfix.so +0 -0
- data/lib/3.4/quickfix.so +0 -0
- data/lib/quickfix40.rb +274 -0
- data/lib/quickfix41.rb +351 -0
- data/lib/quickfix42.rb +1184 -0
- data/lib/quickfix43.rb +3504 -0
- data/lib/quickfix44.rb +14040 -0
- data/lib/quickfix50.rb +20051 -0
- data/lib/quickfix50sp1.rb +23596 -0
- data/lib/quickfix50sp2.rb +412444 -0
- data/lib/quickfix_fields.rb +79393 -0
- data/lib/quickfix_ruby.rb +82 -0
- data/lib/quickfixt11.rb +65 -0
- data/spec/FIX40.xml +862 -0
- data/spec/FIX41.xml +1282 -0
- data/spec/FIX42.xml +2743 -0
- data/spec/FIX43.xml +4230 -0
- data/spec/FIX44.xml +6600 -0
- data/spec/FIX50.xml +8142 -0
- data/spec/FIX50SP1.xml +9506 -0
- data/spec/FIX50SP2.xml +26069 -0
- data/spec/FIXT11.xml +252 -0
- data/test/DataDictionaryTestCase.rb +268 -0
- data/test/DictionaryTestCase.rb +112 -0
- data/test/FieldBaseTestCase.rb +24 -0
- data/test/MessageStoreTestCase.rb +19 -0
- data/test/MessageTestCase.rb +368 -0
- data/test/SessionSettingsTestCase.rb +41 -0
- metadata +247 -0
@@ -0,0 +1,144 @@
|
|
1
|
+
// Copyright 2010 the V8 project authors. All rights reserved.
|
2
|
+
// Redistribution and use in source and binary forms, with or without
|
3
|
+
// modification, are permitted provided that the following conditions are
|
4
|
+
// met:
|
5
|
+
//
|
6
|
+
// * Redistributions of source code must retain the above copyright
|
7
|
+
// notice, this list of conditions and the following disclaimer.
|
8
|
+
// * Redistributions in binary form must reproduce the above
|
9
|
+
// copyright notice, this list of conditions and the following
|
10
|
+
// disclaimer in the documentation and/or other materials provided
|
11
|
+
// with the distribution.
|
12
|
+
// * Neither the name of Google Inc. nor the names of its
|
13
|
+
// contributors may be used to endorse or promote products derived
|
14
|
+
// from this software without specific prior written permission.
|
15
|
+
//
|
16
|
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
17
|
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
18
|
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
19
|
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
20
|
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
21
|
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
22
|
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
23
|
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
24
|
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
25
|
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
26
|
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
27
|
+
|
28
|
+
#ifndef DOUBLE_CONVERSION_BIGNUM_H_
|
29
|
+
#define DOUBLE_CONVERSION_BIGNUM_H_
|
30
|
+
|
31
|
+
#include "double-conversion/utils.h"
|
32
|
+
|
33
|
+
namespace double_conversion {
|
34
|
+
|
35
|
+
class Bignum {
|
36
|
+
public:
|
37
|
+
// 3584 = 128 * 28. We can represent 2^3584 > 10^1000 accurately.
|
38
|
+
// This bignum can encode much bigger numbers, since it contains an
|
39
|
+
// exponent.
|
40
|
+
static const int kMaxSignificantBits = 3584;
|
41
|
+
|
42
|
+
Bignum();
|
43
|
+
void AssignUInt16(uint16_t value);
|
44
|
+
void AssignUInt64(uint64_t value);
|
45
|
+
void AssignBignum(const Bignum& other);
|
46
|
+
|
47
|
+
void AssignDecimalString(Vector<const char> value);
|
48
|
+
void AssignHexString(Vector<const char> value);
|
49
|
+
|
50
|
+
void AssignPowerUInt16(uint16_t base, int exponent);
|
51
|
+
|
52
|
+
void AddUInt64(uint64_t operand);
|
53
|
+
void AddBignum(const Bignum& other);
|
54
|
+
// Precondition: this >= other.
|
55
|
+
void SubtractBignum(const Bignum& other);
|
56
|
+
|
57
|
+
void Square();
|
58
|
+
void ShiftLeft(int shift_amount);
|
59
|
+
void MultiplyByUInt32(uint32_t factor);
|
60
|
+
void MultiplyByUInt64(uint64_t factor);
|
61
|
+
void MultiplyByPowerOfTen(int exponent);
|
62
|
+
void Times10() { return MultiplyByUInt32(10); }
|
63
|
+
// Pseudocode:
|
64
|
+
// int result = this / other;
|
65
|
+
// this = this % other;
|
66
|
+
// In the worst case this function is in O(this/other).
|
67
|
+
uint16_t DivideModuloIntBignum(const Bignum& other);
|
68
|
+
|
69
|
+
bool ToHexString(char* buffer, int buffer_size) const;
|
70
|
+
|
71
|
+
// Returns
|
72
|
+
// -1 if a < b,
|
73
|
+
// 0 if a == b, and
|
74
|
+
// +1 if a > b.
|
75
|
+
static int Compare(const Bignum& a, const Bignum& b);
|
76
|
+
static bool Equal(const Bignum& a, const Bignum& b) {
|
77
|
+
return Compare(a, b) == 0;
|
78
|
+
}
|
79
|
+
static bool LessEqual(const Bignum& a, const Bignum& b) {
|
80
|
+
return Compare(a, b) <= 0;
|
81
|
+
}
|
82
|
+
static bool Less(const Bignum& a, const Bignum& b) {
|
83
|
+
return Compare(a, b) < 0;
|
84
|
+
}
|
85
|
+
// Returns Compare(a + b, c);
|
86
|
+
static int PlusCompare(const Bignum& a, const Bignum& b, const Bignum& c);
|
87
|
+
// Returns a + b == c
|
88
|
+
static bool PlusEqual(const Bignum& a, const Bignum& b, const Bignum& c) {
|
89
|
+
return PlusCompare(a, b, c) == 0;
|
90
|
+
}
|
91
|
+
// Returns a + b <= c
|
92
|
+
static bool PlusLessEqual(const Bignum& a, const Bignum& b, const Bignum& c) {
|
93
|
+
return PlusCompare(a, b, c) <= 0;
|
94
|
+
}
|
95
|
+
// Returns a + b < c
|
96
|
+
static bool PlusLess(const Bignum& a, const Bignum& b, const Bignum& c) {
|
97
|
+
return PlusCompare(a, b, c) < 0;
|
98
|
+
}
|
99
|
+
private:
|
100
|
+
typedef uint32_t Chunk;
|
101
|
+
typedef uint64_t DoubleChunk;
|
102
|
+
|
103
|
+
static const int kChunkSize = sizeof(Chunk) * 8;
|
104
|
+
static const int kDoubleChunkSize = sizeof(DoubleChunk) * 8;
|
105
|
+
// With bigit size of 28 we loose some bits, but a double still fits easily
|
106
|
+
// into two chunks, and more importantly we can use the Comba multiplication.
|
107
|
+
static const int kBigitSize = 28;
|
108
|
+
static const Chunk kBigitMask = (1 << kBigitSize) - 1;
|
109
|
+
// Every instance allocates kBigitLength chunks on the stack. Bignums cannot
|
110
|
+
// grow. There are no checks if the stack-allocated space is sufficient.
|
111
|
+
static const int kBigitCapacity = kMaxSignificantBits / kBigitSize;
|
112
|
+
|
113
|
+
void EnsureCapacity(int size) {
|
114
|
+
if (size > kBigitCapacity) {
|
115
|
+
UNREACHABLE();
|
116
|
+
}
|
117
|
+
}
|
118
|
+
void Align(const Bignum& other);
|
119
|
+
void Clamp();
|
120
|
+
bool IsClamped() const;
|
121
|
+
void Zero();
|
122
|
+
// Requires this to have enough capacity (no tests done).
|
123
|
+
// Updates used_digits_ if necessary.
|
124
|
+
// shift_amount must be < kBigitSize.
|
125
|
+
void BigitsShiftLeft(int shift_amount);
|
126
|
+
// BigitLength includes the "hidden" digits encoded in the exponent.
|
127
|
+
int BigitLength() const { return used_digits_ + exponent_; }
|
128
|
+
Chunk BigitAt(int index) const;
|
129
|
+
void SubtractTimes(const Bignum& other, int factor);
|
130
|
+
|
131
|
+
Chunk bigits_buffer_[kBigitCapacity];
|
132
|
+
// A vector backed by bigits_buffer_. This way accesses to the array are
|
133
|
+
// checked for out-of-bounds errors.
|
134
|
+
Vector<Chunk> bigits_;
|
135
|
+
int used_digits_;
|
136
|
+
// The Bignum's value equals value(bigits_) * 2^(exponent_ * kBigitSize).
|
137
|
+
int exponent_;
|
138
|
+
|
139
|
+
DISALLOW_COPY_AND_ASSIGN(Bignum);
|
140
|
+
};
|
141
|
+
|
142
|
+
} // namespace double_conversion
|
143
|
+
|
144
|
+
#endif // DOUBLE_CONVERSION_BIGNUM_H_
|
@@ -0,0 +1,176 @@
|
|
1
|
+
// Copyright 2006-2008 the V8 project authors. All rights reserved.
|
2
|
+
// Redistribution and use in source and binary forms, with or without
|
3
|
+
// modification, are permitted provided that the following conditions are
|
4
|
+
// met:
|
5
|
+
//
|
6
|
+
// * Redistributions of source code must retain the above copyright
|
7
|
+
// notice, this list of conditions and the following disclaimer.
|
8
|
+
// * Redistributions in binary form must reproduce the above
|
9
|
+
// copyright notice, this list of conditions and the following
|
10
|
+
// disclaimer in the documentation and/or other materials provided
|
11
|
+
// with the distribution.
|
12
|
+
// * Neither the name of Google Inc. nor the names of its
|
13
|
+
// contributors may be used to endorse or promote products derived
|
14
|
+
// from this software without specific prior written permission.
|
15
|
+
//
|
16
|
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
17
|
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
18
|
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
19
|
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
20
|
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
21
|
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
22
|
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
23
|
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
24
|
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
25
|
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
26
|
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
27
|
+
|
28
|
+
#include <stdarg.h>
|
29
|
+
#include <limits.h>
|
30
|
+
#include <math.h>
|
31
|
+
|
32
|
+
#include "double-conversion/utils.h"
|
33
|
+
|
34
|
+
#include "cached-powers.h"
|
35
|
+
|
36
|
+
namespace double_conversion {
|
37
|
+
|
38
|
+
struct CachedPower {
|
39
|
+
uint64_t significand;
|
40
|
+
int16_t binary_exponent;
|
41
|
+
int16_t decimal_exponent;
|
42
|
+
};
|
43
|
+
|
44
|
+
static const CachedPower kCachedPowers[] = {
|
45
|
+
{UINT64_2PART_C(0xfa8fd5a0, 081c0288), -1220, -348},
|
46
|
+
{UINT64_2PART_C(0xbaaee17f, a23ebf76), -1193, -340},
|
47
|
+
{UINT64_2PART_C(0x8b16fb20, 3055ac76), -1166, -332},
|
48
|
+
{UINT64_2PART_C(0xcf42894a, 5dce35ea), -1140, -324},
|
49
|
+
{UINT64_2PART_C(0x9a6bb0aa, 55653b2d), -1113, -316},
|
50
|
+
{UINT64_2PART_C(0xe61acf03, 3d1a45df), -1087, -308},
|
51
|
+
{UINT64_2PART_C(0xab70fe17, c79ac6ca), -1060, -300},
|
52
|
+
{UINT64_2PART_C(0xff77b1fc, bebcdc4f), -1034, -292},
|
53
|
+
{UINT64_2PART_C(0xbe5691ef, 416bd60c), -1007, -284},
|
54
|
+
{UINT64_2PART_C(0x8dd01fad, 907ffc3c), -980, -276},
|
55
|
+
{UINT64_2PART_C(0xd3515c28, 31559a83), -954, -268},
|
56
|
+
{UINT64_2PART_C(0x9d71ac8f, ada6c9b5), -927, -260},
|
57
|
+
{UINT64_2PART_C(0xea9c2277, 23ee8bcb), -901, -252},
|
58
|
+
{UINT64_2PART_C(0xaecc4991, 4078536d), -874, -244},
|
59
|
+
{UINT64_2PART_C(0x823c1279, 5db6ce57), -847, -236},
|
60
|
+
{UINT64_2PART_C(0xc2109436, 4dfb5637), -821, -228},
|
61
|
+
{UINT64_2PART_C(0x9096ea6f, 3848984f), -794, -220},
|
62
|
+
{UINT64_2PART_C(0xd77485cb, 25823ac7), -768, -212},
|
63
|
+
{UINT64_2PART_C(0xa086cfcd, 97bf97f4), -741, -204},
|
64
|
+
{UINT64_2PART_C(0xef340a98, 172aace5), -715, -196},
|
65
|
+
{UINT64_2PART_C(0xb23867fb, 2a35b28e), -688, -188},
|
66
|
+
{UINT64_2PART_C(0x84c8d4df, d2c63f3b), -661, -180},
|
67
|
+
{UINT64_2PART_C(0xc5dd4427, 1ad3cdba), -635, -172},
|
68
|
+
{UINT64_2PART_C(0x936b9fce, bb25c996), -608, -164},
|
69
|
+
{UINT64_2PART_C(0xdbac6c24, 7d62a584), -582, -156},
|
70
|
+
{UINT64_2PART_C(0xa3ab6658, 0d5fdaf6), -555, -148},
|
71
|
+
{UINT64_2PART_C(0xf3e2f893, dec3f126), -529, -140},
|
72
|
+
{UINT64_2PART_C(0xb5b5ada8, aaff80b8), -502, -132},
|
73
|
+
{UINT64_2PART_C(0x87625f05, 6c7c4a8b), -475, -124},
|
74
|
+
{UINT64_2PART_C(0xc9bcff60, 34c13053), -449, -116},
|
75
|
+
{UINT64_2PART_C(0x964e858c, 91ba2655), -422, -108},
|
76
|
+
{UINT64_2PART_C(0xdff97724, 70297ebd), -396, -100},
|
77
|
+
{UINT64_2PART_C(0xa6dfbd9f, b8e5b88f), -369, -92},
|
78
|
+
{UINT64_2PART_C(0xf8a95fcf, 88747d94), -343, -84},
|
79
|
+
{UINT64_2PART_C(0xb9447093, 8fa89bcf), -316, -76},
|
80
|
+
{UINT64_2PART_C(0x8a08f0f8, bf0f156b), -289, -68},
|
81
|
+
{UINT64_2PART_C(0xcdb02555, 653131b6), -263, -60},
|
82
|
+
{UINT64_2PART_C(0x993fe2c6, d07b7fac), -236, -52},
|
83
|
+
{UINT64_2PART_C(0xe45c10c4, 2a2b3b06), -210, -44},
|
84
|
+
{UINT64_2PART_C(0xaa242499, 697392d3), -183, -36},
|
85
|
+
{UINT64_2PART_C(0xfd87b5f2, 8300ca0e), -157, -28},
|
86
|
+
{UINT64_2PART_C(0xbce50864, 92111aeb), -130, -20},
|
87
|
+
{UINT64_2PART_C(0x8cbccc09, 6f5088cc), -103, -12},
|
88
|
+
{UINT64_2PART_C(0xd1b71758, e219652c), -77, -4},
|
89
|
+
{UINT64_2PART_C(0x9c400000, 00000000), -50, 4},
|
90
|
+
{UINT64_2PART_C(0xe8d4a510, 00000000), -24, 12},
|
91
|
+
{UINT64_2PART_C(0xad78ebc5, ac620000), 3, 20},
|
92
|
+
{UINT64_2PART_C(0x813f3978, f8940984), 30, 28},
|
93
|
+
{UINT64_2PART_C(0xc097ce7b, c90715b3), 56, 36},
|
94
|
+
{UINT64_2PART_C(0x8f7e32ce, 7bea5c70), 83, 44},
|
95
|
+
{UINT64_2PART_C(0xd5d238a4, abe98068), 109, 52},
|
96
|
+
{UINT64_2PART_C(0x9f4f2726, 179a2245), 136, 60},
|
97
|
+
{UINT64_2PART_C(0xed63a231, d4c4fb27), 162, 68},
|
98
|
+
{UINT64_2PART_C(0xb0de6538, 8cc8ada8), 189, 76},
|
99
|
+
{UINT64_2PART_C(0x83c7088e, 1aab65db), 216, 84},
|
100
|
+
{UINT64_2PART_C(0xc45d1df9, 42711d9a), 242, 92},
|
101
|
+
{UINT64_2PART_C(0x924d692c, a61be758), 269, 100},
|
102
|
+
{UINT64_2PART_C(0xda01ee64, 1a708dea), 295, 108},
|
103
|
+
{UINT64_2PART_C(0xa26da399, 9aef774a), 322, 116},
|
104
|
+
{UINT64_2PART_C(0xf209787b, b47d6b85), 348, 124},
|
105
|
+
{UINT64_2PART_C(0xb454e4a1, 79dd1877), 375, 132},
|
106
|
+
{UINT64_2PART_C(0x865b8692, 5b9bc5c2), 402, 140},
|
107
|
+
{UINT64_2PART_C(0xc83553c5, c8965d3d), 428, 148},
|
108
|
+
{UINT64_2PART_C(0x952ab45c, fa97a0b3), 455, 156},
|
109
|
+
{UINT64_2PART_C(0xde469fbd, 99a05fe3), 481, 164},
|
110
|
+
{UINT64_2PART_C(0xa59bc234, db398c25), 508, 172},
|
111
|
+
{UINT64_2PART_C(0xf6c69a72, a3989f5c), 534, 180},
|
112
|
+
{UINT64_2PART_C(0xb7dcbf53, 54e9bece), 561, 188},
|
113
|
+
{UINT64_2PART_C(0x88fcf317, f22241e2), 588, 196},
|
114
|
+
{UINT64_2PART_C(0xcc20ce9b, d35c78a5), 614, 204},
|
115
|
+
{UINT64_2PART_C(0x98165af3, 7b2153df), 641, 212},
|
116
|
+
{UINT64_2PART_C(0xe2a0b5dc, 971f303a), 667, 220},
|
117
|
+
{UINT64_2PART_C(0xa8d9d153, 5ce3b396), 694, 228},
|
118
|
+
{UINT64_2PART_C(0xfb9b7cd9, a4a7443c), 720, 236},
|
119
|
+
{UINT64_2PART_C(0xbb764c4c, a7a44410), 747, 244},
|
120
|
+
{UINT64_2PART_C(0x8bab8eef, b6409c1a), 774, 252},
|
121
|
+
{UINT64_2PART_C(0xd01fef10, a657842c), 800, 260},
|
122
|
+
{UINT64_2PART_C(0x9b10a4e5, e9913129), 827, 268},
|
123
|
+
{UINT64_2PART_C(0xe7109bfb, a19c0c9d), 853, 276},
|
124
|
+
{UINT64_2PART_C(0xac2820d9, 623bf429), 880, 284},
|
125
|
+
{UINT64_2PART_C(0x80444b5e, 7aa7cf85), 907, 292},
|
126
|
+
{UINT64_2PART_C(0xbf21e440, 03acdd2d), 933, 300},
|
127
|
+
{UINT64_2PART_C(0x8e679c2f, 5e44ff8f), 960, 308},
|
128
|
+
{UINT64_2PART_C(0xd433179d, 9c8cb841), 986, 316},
|
129
|
+
{UINT64_2PART_C(0x9e19db92, b4e31ba9), 1013, 324},
|
130
|
+
{UINT64_2PART_C(0xeb96bf6e, badf77d9), 1039, 332},
|
131
|
+
{UINT64_2PART_C(0xaf87023b, 9bf0ee6b), 1066, 340},
|
132
|
+
};
|
133
|
+
|
134
|
+
static const int kCachedPowersLength = ARRAY_SIZE(kCachedPowers);
|
135
|
+
static const int kCachedPowersOffset = 348; // -1 * the first decimal_exponent.
|
136
|
+
static const double kD_1_LOG2_10 = 0.30102999566398114; // 1 / lg(10)
|
137
|
+
// Difference between the decimal exponents in the table above.
|
138
|
+
const int PowersOfTenCache::kDecimalExponentDistance = 8;
|
139
|
+
const int PowersOfTenCache::kMinDecimalExponent = -348;
|
140
|
+
const int PowersOfTenCache::kMaxDecimalExponent = 340;
|
141
|
+
|
142
|
+
void PowersOfTenCache::GetCachedPowerForBinaryExponentRange(
|
143
|
+
int min_exponent,
|
144
|
+
int max_exponent,
|
145
|
+
DiyFp* power,
|
146
|
+
int* decimal_exponent) {
|
147
|
+
int kQ = DiyFp::kSignificandSize;
|
148
|
+
double k = ceil((min_exponent + kQ - 1) * kD_1_LOG2_10);
|
149
|
+
int foo = kCachedPowersOffset;
|
150
|
+
int index =
|
151
|
+
(foo + static_cast<int>(k) - 1) / kDecimalExponentDistance + 1;
|
152
|
+
ASSERT(0 <= index && index < kCachedPowersLength);
|
153
|
+
CachedPower cached_power = kCachedPowers[index];
|
154
|
+
ASSERT(min_exponent <= cached_power.binary_exponent);
|
155
|
+
(void) max_exponent; // Mark variable as used.
|
156
|
+
ASSERT(cached_power.binary_exponent <= max_exponent);
|
157
|
+
*decimal_exponent = cached_power.decimal_exponent;
|
158
|
+
*power = DiyFp(cached_power.significand, cached_power.binary_exponent);
|
159
|
+
}
|
160
|
+
|
161
|
+
|
162
|
+
void PowersOfTenCache::GetCachedPowerForDecimalExponent(int requested_exponent,
|
163
|
+
DiyFp* power,
|
164
|
+
int* found_exponent) {
|
165
|
+
ASSERT(kMinDecimalExponent <= requested_exponent);
|
166
|
+
ASSERT(requested_exponent < kMaxDecimalExponent + kDecimalExponentDistance);
|
167
|
+
int index =
|
168
|
+
(requested_exponent + kCachedPowersOffset) / kDecimalExponentDistance;
|
169
|
+
CachedPower cached_power = kCachedPowers[index];
|
170
|
+
*power = DiyFp(cached_power.significand, cached_power.binary_exponent);
|
171
|
+
*found_exponent = cached_power.decimal_exponent;
|
172
|
+
ASSERT(*found_exponent <= requested_exponent);
|
173
|
+
ASSERT(requested_exponent < *found_exponent + kDecimalExponentDistance);
|
174
|
+
}
|
175
|
+
|
176
|
+
} // namespace double_conversion
|
@@ -0,0 +1,64 @@
|
|
1
|
+
// Copyright 2010 the V8 project authors. All rights reserved.
|
2
|
+
// Redistribution and use in source and binary forms, with or without
|
3
|
+
// modification, are permitted provided that the following conditions are
|
4
|
+
// met:
|
5
|
+
//
|
6
|
+
// * Redistributions of source code must retain the above copyright
|
7
|
+
// notice, this list of conditions and the following disclaimer.
|
8
|
+
// * Redistributions in binary form must reproduce the above
|
9
|
+
// copyright notice, this list of conditions and the following
|
10
|
+
// disclaimer in the documentation and/or other materials provided
|
11
|
+
// with the distribution.
|
12
|
+
// * Neither the name of Google Inc. nor the names of its
|
13
|
+
// contributors may be used to endorse or promote products derived
|
14
|
+
// from this software without specific prior written permission.
|
15
|
+
//
|
16
|
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
17
|
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
18
|
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
19
|
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
20
|
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
21
|
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
22
|
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
23
|
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
24
|
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
25
|
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
26
|
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
27
|
+
|
28
|
+
#ifndef DOUBLE_CONVERSION_CACHED_POWERS_H_
|
29
|
+
#define DOUBLE_CONVERSION_CACHED_POWERS_H_
|
30
|
+
|
31
|
+
#include "diy-fp.h"
|
32
|
+
|
33
|
+
namespace double_conversion {
|
34
|
+
|
35
|
+
class PowersOfTenCache {
|
36
|
+
public:
|
37
|
+
|
38
|
+
// Not all powers of ten are cached. The decimal exponent of two neighboring
|
39
|
+
// cached numbers will differ by kDecimalExponentDistance.
|
40
|
+
static const int kDecimalExponentDistance;
|
41
|
+
|
42
|
+
static const int kMinDecimalExponent;
|
43
|
+
static const int kMaxDecimalExponent;
|
44
|
+
|
45
|
+
// Returns a cached power-of-ten with a binary exponent in the range
|
46
|
+
// [min_exponent; max_exponent] (boundaries included).
|
47
|
+
static void GetCachedPowerForBinaryExponentRange(int min_exponent,
|
48
|
+
int max_exponent,
|
49
|
+
DiyFp* power,
|
50
|
+
int* decimal_exponent);
|
51
|
+
|
52
|
+
// Returns a cached power of ten x ~= 10^k such that
|
53
|
+
// k <= decimal_exponent < k + kCachedPowersDecimalDistance.
|
54
|
+
// The given decimal_exponent must satisfy
|
55
|
+
// kMinDecimalExponent <= requested_exponent, and
|
56
|
+
// requested_exponent < kMaxDecimalExponent + kDecimalExponentDistance.
|
57
|
+
static void GetCachedPowerForDecimalExponent(int requested_exponent,
|
58
|
+
DiyFp* power,
|
59
|
+
int* found_exponent);
|
60
|
+
};
|
61
|
+
|
62
|
+
} // namespace double_conversion
|
63
|
+
|
64
|
+
#endif // DOUBLE_CONVERSION_CACHED_POWERS_H_
|
@@ -0,0 +1,57 @@
|
|
1
|
+
// Copyright 2010 the V8 project authors. All rights reserved.
|
2
|
+
// Redistribution and use in source and binary forms, with or without
|
3
|
+
// modification, are permitted provided that the following conditions are
|
4
|
+
// met:
|
5
|
+
//
|
6
|
+
// * Redistributions of source code must retain the above copyright
|
7
|
+
// notice, this list of conditions and the following disclaimer.
|
8
|
+
// * Redistributions in binary form must reproduce the above
|
9
|
+
// copyright notice, this list of conditions and the following
|
10
|
+
// disclaimer in the documentation and/or other materials provided
|
11
|
+
// with the distribution.
|
12
|
+
// * Neither the name of Google Inc. nor the names of its
|
13
|
+
// contributors may be used to endorse or promote products derived
|
14
|
+
// from this software without specific prior written permission.
|
15
|
+
//
|
16
|
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
17
|
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
18
|
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
19
|
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
20
|
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
21
|
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
22
|
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
23
|
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
24
|
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
25
|
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
26
|
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
27
|
+
|
28
|
+
|
29
|
+
#include "double-conversion/diy-fp.h"
|
30
|
+
#include "double-conversion/utils.h"
|
31
|
+
|
32
|
+
namespace double_conversion {
|
33
|
+
|
34
|
+
void DiyFp::Multiply(const DiyFp& other) {
|
35
|
+
// Simply "emulates" a 128 bit multiplication.
|
36
|
+
// However: the resulting number only contains 64 bits. The least
|
37
|
+
// significant 64 bits are only used for rounding the most significant 64
|
38
|
+
// bits.
|
39
|
+
const uint64_t kM32 = 0xFFFFFFFFU;
|
40
|
+
uint64_t a = f_ >> 32;
|
41
|
+
uint64_t b = f_ & kM32;
|
42
|
+
uint64_t c = other.f_ >> 32;
|
43
|
+
uint64_t d = other.f_ & kM32;
|
44
|
+
uint64_t ac = a * c;
|
45
|
+
uint64_t bc = b * c;
|
46
|
+
uint64_t ad = a * d;
|
47
|
+
uint64_t bd = b * d;
|
48
|
+
uint64_t tmp = (bd >> 32) + (ad & kM32) + (bc & kM32);
|
49
|
+
// By adding 1U << 31 to tmp we round the final result.
|
50
|
+
// Halfway cases will be round up.
|
51
|
+
tmp += 1U << 31;
|
52
|
+
uint64_t result_f = ac + (ad >> 32) + (bc >> 32) + (tmp >> 32);
|
53
|
+
e_ += other.e_ + 64;
|
54
|
+
f_ = result_f;
|
55
|
+
}
|
56
|
+
|
57
|
+
} // namespace double_conversion
|
@@ -0,0 +1,118 @@
|
|
1
|
+
// Copyright 2010 the V8 project authors. All rights reserved.
|
2
|
+
// Redistribution and use in source and binary forms, with or without
|
3
|
+
// modification, are permitted provided that the following conditions are
|
4
|
+
// met:
|
5
|
+
//
|
6
|
+
// * Redistributions of source code must retain the above copyright
|
7
|
+
// notice, this list of conditions and the following disclaimer.
|
8
|
+
// * Redistributions in binary form must reproduce the above
|
9
|
+
// copyright notice, this list of conditions and the following
|
10
|
+
// disclaimer in the documentation and/or other materials provided
|
11
|
+
// with the distribution.
|
12
|
+
// * Neither the name of Google Inc. nor the names of its
|
13
|
+
// contributors may be used to endorse or promote products derived
|
14
|
+
// from this software without specific prior written permission.
|
15
|
+
//
|
16
|
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
17
|
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
18
|
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
19
|
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
20
|
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
21
|
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
22
|
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
23
|
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
24
|
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
25
|
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
26
|
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
27
|
+
|
28
|
+
#ifndef DOUBLE_CONVERSION_DIY_FP_H_
|
29
|
+
#define DOUBLE_CONVERSION_DIY_FP_H_
|
30
|
+
|
31
|
+
#include "double-conversion/utils.h"
|
32
|
+
|
33
|
+
namespace double_conversion {
|
34
|
+
|
35
|
+
// This "Do It Yourself Floating Point" class implements a floating-point number
|
36
|
+
// with a uint64 significand and an int exponent. Normalized DiyFp numbers will
|
37
|
+
// have the most significant bit of the significand set.
|
38
|
+
// Multiplication and Subtraction do not normalize their results.
|
39
|
+
// DiyFp are not designed to contain special doubles (NaN and Infinity).
|
40
|
+
class DiyFp {
|
41
|
+
public:
|
42
|
+
static const int kSignificandSize = 64;
|
43
|
+
|
44
|
+
DiyFp() : f_(0), e_(0) {}
|
45
|
+
DiyFp(uint64_t significand, int exponent) : f_(significand), e_(exponent) {}
|
46
|
+
|
47
|
+
// this = this - other.
|
48
|
+
// The exponents of both numbers must be the same and the significand of this
|
49
|
+
// must be bigger than the significand of other.
|
50
|
+
// The result will not be normalized.
|
51
|
+
void Subtract(const DiyFp& other) {
|
52
|
+
ASSERT(e_ == other.e_);
|
53
|
+
ASSERT(f_ >= other.f_);
|
54
|
+
f_ -= other.f_;
|
55
|
+
}
|
56
|
+
|
57
|
+
// Returns a - b.
|
58
|
+
// The exponents of both numbers must be the same and this must be bigger
|
59
|
+
// than other. The result will not be normalized.
|
60
|
+
static DiyFp Minus(const DiyFp& a, const DiyFp& b) {
|
61
|
+
DiyFp result = a;
|
62
|
+
result.Subtract(b);
|
63
|
+
return result;
|
64
|
+
}
|
65
|
+
|
66
|
+
|
67
|
+
// this = this * other.
|
68
|
+
void Multiply(const DiyFp& other);
|
69
|
+
|
70
|
+
// returns a * b;
|
71
|
+
static DiyFp Times(const DiyFp& a, const DiyFp& b) {
|
72
|
+
DiyFp result = a;
|
73
|
+
result.Multiply(b);
|
74
|
+
return result;
|
75
|
+
}
|
76
|
+
|
77
|
+
void Normalize() {
|
78
|
+
ASSERT(f_ != 0);
|
79
|
+
uint64_t significand = f_;
|
80
|
+
int exponent = e_;
|
81
|
+
|
82
|
+
// This method is mainly called for normalizing boundaries. In general
|
83
|
+
// boundaries need to be shifted by 10 bits. We thus optimize for this case.
|
84
|
+
const uint64_t k10MSBits = UINT64_2PART_C(0xFFC00000, 00000000);
|
85
|
+
while ((significand & k10MSBits) == 0) {
|
86
|
+
significand <<= 10;
|
87
|
+
exponent -= 10;
|
88
|
+
}
|
89
|
+
while ((significand & kUint64MSB) == 0) {
|
90
|
+
significand <<= 1;
|
91
|
+
exponent--;
|
92
|
+
}
|
93
|
+
f_ = significand;
|
94
|
+
e_ = exponent;
|
95
|
+
}
|
96
|
+
|
97
|
+
static DiyFp Normalize(const DiyFp& a) {
|
98
|
+
DiyFp result = a;
|
99
|
+
result.Normalize();
|
100
|
+
return result;
|
101
|
+
}
|
102
|
+
|
103
|
+
uint64_t f() const { return f_; }
|
104
|
+
int e() const { return e_; }
|
105
|
+
|
106
|
+
void set_f(uint64_t new_value) { f_ = new_value; }
|
107
|
+
void set_e(int new_value) { e_ = new_value; }
|
108
|
+
|
109
|
+
private:
|
110
|
+
static const uint64_t kUint64MSB = UINT64_2PART_C(0x80000000, 00000000);
|
111
|
+
|
112
|
+
uint64_t f_;
|
113
|
+
int e_;
|
114
|
+
};
|
115
|
+
|
116
|
+
} // namespace double_conversion
|
117
|
+
|
118
|
+
#endif // DOUBLE_CONVERSION_DIY_FP_H_
|