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 514 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 529 of file gnucash_core.py.

529  def __init__(self, *args, **kargs):
530  """Constructor that supports the following formats:
531  * No arguments defaulting to zero: eg. GncNumeric() == 0/1
532  * A integer: e.g. GncNumeric(1) == 1/1
533  * Numerator and denominator intager pair: eg. GncNumeric(1, 2) == 1/2
534  * A floating point number: e.g. GncNumeric(0.5) == 1/2
535  * A floating point number with defined conversion: e.g.
536  GncNumeric(0.5, GNC_DENOM_AUTO,
537  GNC_HOW_DENOM_FIXED | GNC_HOW_RND_NEVER) == 1/2
538  * A string: e.g. GncNumeric("1/2") == 1/2
539  """
540  if 'instance' not in kargs:
541  kargs['instance'] = GncNumeric.__args_to_instance(args)
542  GnuCashCoreClass.__init__(self, [], **kargs)
543 

Member Function Documentation

◆ __abs__()

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

Definition at line 701 of file gnucash_core.py.

701  def __abs__(a):
702  """abs(a)"""
703  return a.abs()
704 

◆ __bool__()

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

Definition at line 683 of file gnucash_core.py.

683  def __bool__(a):
684  """a != 0"""
685  return bool(a.num())
686 

◆ __eq__()

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

Definition at line 679 of file gnucash_core.py.

679  def __eq__(a, b):
680  """a == b"""
681  return a._richcmp(b, a._eq)
682 

◆ __ge__()

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

Definition at line 675 of file gnucash_core.py.

675  def __ge__(a, b):
676  """a >= b"""
677  return a._richcmp(b, a._ge)
678 

◆ __gt__()

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

Definition at line 667 of file gnucash_core.py.

667  def __gt__(a, b):
668  """a > b"""
669  return a._richcmp(b, a._gt)
670 

◆ __le__()

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

Definition at line 671 of file gnucash_core.py.

671  def __le__(a, b):
672  """a <= b"""
673  return a._richcmp(b, a._le)
674 

◆ __lt__()

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

Definition at line 663 of file gnucash_core.py.

663  def __lt__(a, b):
664  """a < b"""
665  return a._richcmp(b, a._lt)
666 

◆ __neg__()

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

Definition at line 697 of file gnucash_core.py.

697  def __neg__(a):
698  """-a"""
699  return a.neg()
700 

◆ __pos__()

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

Definition at line 693 of file gnucash_core.py.

693  def __pos__(a):
694  """+a"""
695  return GncNumeric(a.num(), a.denom())
696 
The primary numeric class for representing amounts and values.
Definition: gnc-numeric.hpp:59

◆ __str__()

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

Definition at line 709 of file gnucash_core.py.

709  def __str__(self):
710  """Returns a human readable numeric value string as UTF8."""
711  return gnc_numeric_to_string(self.instance)
712 
gchar * gnc_numeric_to_string(gnc_numeric n)
Convert to string.

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