Warning, /office/calligra/sheets/doc/NOTES.high-precision is written in an unsupported language. File is not indexed.
0001 Number class 0002 ============ 0003 0004 Requirements 0005 ------------ 0006 - Should increase the numerical precision. 0007 - Should fallback to (long) double and use its operators directly, 0008 so that the code could be optimized by the compiler. 0009 - High precision support should be either: 0010 - a run-time option by using plugins (preferred) 0011 - a compile-time option 0012 0013 Options 0014 ------- 0015 - static polymorphism: CRTP 0016 - dynamic polymorphism: interface is a usual class with pure virtual methods; 0017 Q_DECLARE_INTERFACE, Q_INTERFACES can be used here 0018 - QVariant/QMetaType allows to create objects dynamically on run-time: 0019 - double can be used directly 0020 - custom types actually too, but dynamic polymorphism needs pointers 0021 - QMetaType::construct() returns void* 0022 - using QVariant in the calculation methods to carry the number and create 0023 a double or the custom type at run-time is possible 0024 0025 Advantages/Drawbacks/Conclusion 0026 ------------------------------- 0027 - CRTP allows to inline the methods and using (long) double's operators becomes 0028 possible 0029 - using virtuals does not allow to inline the methods, if pointer or references 0030 to the object are used, which is necessary in the case of dynamic binding 0031 - inlining operators does not work with dynamic polymorphism 0032 - having high-precision and the (long) double fallback needs a common base 0033 0034 Impossible solution(s) 0035 ---------------------- 0036 1. 0037 - derive the type using (long) double type from a base using CRTP approach 0038 - derive the interface for the dynamic binding also from this base 0039 - derive concrete implementations from the interface 0040 Reason: 0041 - inserting a dynamically created type as template parameter into the CRTP base 0042 is not possible 0043 2. 0044 - use QVariant as data carrier/common base 0045 - mirror QVariant's behaviour in KSpread::Value 0046 Reason: 0047 - the QVariant::Type does not suffice, you need to know the type in order to use 0048 it 0049 0050 Possible solution(s) 0051 -------------------- 0052 0. 0053 - the information, which type is in use, that's a QVariant::Type, should be 0054 stored per document, more precisely in CalculationSettings 0055 0056 0057 union 0058 { 0059 double a; 0060 void* b; 0061 };