Home | History | Annotate | Download | only in fxcrt
      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 CORE_FXCRT_CFX_DECIMAL_H_
      8 #define CORE_FXCRT_CFX_DECIMAL_H_
      9 
     10 #include "core/fxcrt/fx_string.h"
     11 
     12 class CFX_Decimal {
     13  public:
     14   CFX_Decimal();
     15   explicit CFX_Decimal(uint32_t val);
     16   explicit CFX_Decimal(uint64_t val);
     17   explicit CFX_Decimal(int32_t val);
     18   CFX_Decimal(float val, uint8_t scale);
     19   explicit CFX_Decimal(const WideStringView& str);
     20 
     21   operator WideString() const;
     22   operator double() const;
     23 
     24   CFX_Decimal operator*(const CFX_Decimal& val) const;
     25   CFX_Decimal operator/(const CFX_Decimal& val) const;
     26 
     27   void SetScale(uint8_t newScale);
     28   uint8_t GetScale();
     29   void SetNegate();
     30 
     31  private:
     32   CFX_Decimal(uint32_t hi, uint32_t mid, uint32_t lo, bool neg, uint8_t scale);
     33   bool IsNotZero() const { return m_uHi || m_uMid || m_uLo; }
     34   void Swap(CFX_Decimal& val);
     35 
     36   uint32_t m_uHi;
     37   uint32_t m_uLo;
     38   uint32_t m_uMid;
     39   uint32_t m_uFlags;
     40 };
     41 
     42 #endif  // CORE_FXCRT_CFX_DECIMAL_H_
     43