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 __setattr__ (self, name, value)
 
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 735 of file gnucash_core.py.

735  def __abs__(a):
736  """abs(a)"""
737  return a.abs()
738 

◆ __bool__()

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

Definition at line 717 of file gnucash_core.py.

717  def __bool__(a):
718  """a != 0"""
719  return bool(a.num())
720 

◆ __eq__()

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

Definition at line 713 of file gnucash_core.py.

713  def __eq__(a, b):
714  """a == b"""
715  return a._richcmp(b, a._eq)
716 

◆ __ge__()

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

Definition at line 709 of file gnucash_core.py.

709  def __ge__(a, b):
710  """a >= b"""
711  return a._richcmp(b, a._ge)
712 

◆ __gt__()

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

Definition at line 701 of file gnucash_core.py.

701  def __gt__(a, b):
702  """a > b"""
703  return a._richcmp(b, a._gt)
704 

◆ __le__()

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

Definition at line 705 of file gnucash_core.py.

705  def __le__(a, b):
706  """a <= b"""
707  return a._richcmp(b, a._le)
708 

◆ __lt__()

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

Definition at line 697 of file gnucash_core.py.

697  def __lt__(a, b):
698  """a < b"""
699  return a._richcmp(b, a._lt)
700 

◆ __neg__()

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

Definition at line 731 of file gnucash_core.py.

731  def __neg__(a):
732  """-a"""
733  return a.neg()
734 

◆ __pos__()

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

Definition at line 727 of file gnucash_core.py.

727  def __pos__(a):
728  """+a"""
729  return GncNumeric(a.num(), a.denom())
730 
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 746 of file gnucash_core.py.

746  def __str__(self):
747  """Returns a human readable numeric value string as UTF8."""
748  return gnc_numeric_to_string(self.instance)
749 
gchar * gnc_numeric_to_string(gnc_numeric n)
Convert to string.

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