1 // Copyright 2017 PDFium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 6 7 #ifndef XFA_FGAS_CRT_CFGAS_DECIMAL_H_ 8 #define XFA_FGAS_CRT_CFGAS_DECIMAL_H_ 9 10 #include "core/fxcrt/fx_string.h" 11 12 class CFGAS_Decimal { 13 public: 14 CFGAS_Decimal(); 15 explicit CFGAS_Decimal(uint32_t val); 16 explicit CFGAS_Decimal(uint64_t val); 17 explicit CFGAS_Decimal(int32_t val); 18 CFGAS_Decimal(float val, uint8_t scale); 19 explicit CFGAS_Decimal(WideStringView str); 20 21 WideString ToWideString() const; 22 float ToFloat() const; 23 double ToDouble() const; 24 25 CFGAS_Decimal operator*(const CFGAS_Decimal& val) const; 26 CFGAS_Decimal operator/(const CFGAS_Decimal& val) const; 27 IsNotZero()28 bool IsNotZero() const { return m_uHi || m_uMid || m_uLo; } GetScale()29 uint8_t GetScale() const { return m_uScale; } 30 void SetScale(uint8_t newScale); 31 void SetNegate(); 32 33 private: 34 CFGAS_Decimal(uint32_t hi, 35 uint32_t mid, 36 uint32_t lo, 37 bool neg, 38 uint8_t scale); 39 40 uint32_t m_uHi = 0; 41 uint32_t m_uMid = 0; 42 uint32_t m_uLo = 0; 43 bool m_bNeg = false; 44 uint8_t m_uScale = 0; 45 }; 46 47 #endif // XFA_FGAS_CRT_CFGAS_DECIMAL_H_ 48