GnuCash  5.6-150-g038405b370+
Public Member Functions
python.gnucash_core.GncNumeric Class Reference
Inheritance diagram for python.gnucash_core.GncNumeric:
python.gnucash_core.GnuCashCoreClass

Public Member Functions

def __init__ (self, args, kargs)
 
def __lt__ (a, b)
 
def __gt__ (a, b)
 
def __le__ (a, b)
 
def __ge__ (a, b)
 
def __eq__ (a, b)
 
def __bool__ (a)
 
def __float__ (self)
 
def __int__ (self)
 
def __pos__ (a)
 
def __neg__ (a)
 
def __abs__ (a)
 
def to_fraction (self)
 
def __str__ (self)
 
- Public Member Functions inherited from python.gnucash_core.GnuCashCoreClass
def do_lookup_create_oo_instance (self, lookup_function, cls, args)
 

Detailed Description

Object used by GnuCash to store all numbers. Always consists of a
numerator and denominator.

The constants GNC_DENOM_AUTO,
GNC_HOW_RND_FLOOR, GNC_HOW_RND_CEIL, GNC_HOW_RND_TRUNC,
GNC_HOW_RND_PROMOTE, GNC_HOW_RND_ROUND_HALF_DOWN,
GNC_HOW_RND_ROUND_HALF_UP, GNC_HOW_RND_ROUND, GNC_HOW_RND_NEVER,
GNC_HOW_DENOM_EXACT, GNC_HOW_DENOM_REDUCE, GNC_HOW_DENOM_LCD,
and GNC_HOW_DENOM_FIXED are available for arithmetic
functions like GncNumeric.add

Look at gnc-numeric.h to see how to use these

Definition at line 537 of file gnucash_core.py.

Constructor & Destructor Documentation

◆ __init__()

def python.gnucash_core.GncNumeric.__init__ (   self,
  args,
  kargs 
)
Constructor that supports the following formats:
* No arguments defaulting to zero: eg. GncNumeric() == 0/1
* A integer: e.g. GncNumeric(1) == 1/1
* Numerator and denominator intager pair: eg. GncNumeric(1, 2) == 1/2
* A floating point number: e.g. GncNumeric(0.5) == 1/2
* A floating point number with defined conversion: e.g.
  GncNumeric(0.5, GNC_DENOM_AUTO,
    GNC_HOW_DENOM_FIXED | GNC_HOW_RND_NEVER) == 1/2
* A string: e.g. GncNumeric("1/2") == 1/2

Definition at line 552 of file gnucash_core.py.

552  def __init__(self, *args, **kargs):
553  """Constructor that supports the following formats:
554  * No arguments defaulting to zero: eg. GncNumeric() == 0/1
555  * A integer: e.g. GncNumeric(1) == 1/1
556  * Numerator and denominator intager pair: eg. GncNumeric(1, 2) == 1/2
557  * A floating point number: e.g. GncNumeric(0.5) == 1/2
558  * A floating point number with defined conversion: e.g.
559  GncNumeric(0.5, GNC_DENOM_AUTO,
560  GNC_HOW_DENOM_FIXED | GNC_HOW_RND_NEVER) == 1/2
561  * A string: e.g. GncNumeric("1/2") == 1/2
562  """
563  if 'instance' not in kargs:
564  kargs['instance'] = GncNumeric.__args_to_instance(args)
565  GnuCashCoreClass.__init__(self, [], **kargs)
566 

Member Function Documentation

◆ __abs__()

def python.gnucash_core.GncNumeric.__abs__ (   a)
abs(a)

Definition at line 724 of file gnucash_core.py.

724  def __abs__(a):
725  """abs(a)"""
726  return a.abs()
727 

◆ __bool__()

def python.gnucash_core.GncNumeric.__bool__ (   a)
a != 0

Definition at line 706 of file gnucash_core.py.

706  def __bool__(a):
707  """a != 0"""
708  return bool(a.num())
709 

◆ __eq__()

def python.gnucash_core.GncNumeric.__eq__ (   a,
  b 
)
a == b

Definition at line 702 of file gnucash_core.py.

702  def __eq__(a, b):
703  """a == b"""
704  return a._richcmp(b, a._eq)
705 

◆ __ge__()

def python.gnucash_core.GncNumeric.__ge__ (   a,
  b 
)
a >= b

Definition at line 698 of file gnucash_core.py.

698  def __ge__(a, b):
699  """a >= b"""
700  return a._richcmp(b, a._ge)
701 

◆ __gt__()

def python.gnucash_core.GncNumeric.__gt__ (   a,
  b 
)
a > b

Definition at line 690 of file gnucash_core.py.

690  def __gt__(a, b):
691  """a > b"""
692  return a._richcmp(b, a._gt)
693 

◆ __le__()

def python.gnucash_core.GncNumeric.__le__ (   a,
  b 
)
a <= b

Definition at line 694 of file gnucash_core.py.

694  def __le__(a, b):
695  """a <= b"""
696  return a._richcmp(b, a._le)
697 

◆ __lt__()

def python.gnucash_core.GncNumeric.__lt__ (   a,
  b 
)
a < b

Definition at line 686 of file gnucash_core.py.

686  def __lt__(a, b):
687  """a < b"""
688  return a._richcmp(b, a._lt)
689 

◆ __neg__()

def python.gnucash_core.GncNumeric.__neg__ (   a)
-a

Definition at line 720 of file gnucash_core.py.

720  def __neg__(a):
721  """-a"""
722  return a.neg()
723 

◆ __pos__()

def python.gnucash_core.GncNumeric.__pos__ (   a)
+a

Definition at line 716 of file gnucash_core.py.

716  def __pos__(a):
717  """+a"""
718  return GncNumeric(a.num(), a.denom())
719 
The primary numeric class for representing amounts and values.
Definition: gnc-numeric.hpp:60

◆ __str__()

def python.gnucash_core.GncNumeric.__str__ (   self)
Returns a human readable numeric value string as UTF8.

Definition at line 732 of file gnucash_core.py.

732  def __str__(self):
733  """Returns a human readable numeric value string as UTF8."""
734  return gnc_numeric_to_string(self.instance)
735 
gchar * gnc_numeric_to_string(gnc_numeric n)
Convert to string.

The documentation for this class was generated from the following file: