# Path: num2words/compat.py
# def to_s(val):
#     try:
#         return unicode(val)
#     except NameError:
#         return str(val)
# 
# Path: num2words/currency.py
# def parse_currency_parts(value, is_int_with_cents=True):
#     if isinstance(value, int):
#         if is_int_with_cents:
#             # assume cents if value is integer
#             negative = value < 0
#             value = abs(value)
#             integer, cents = divmod(value, 100)
#         else:
#             negative = value < 0
#             integer, cents = abs(value), 0
# 
#     else:
#         value = Decimal(value)
#         value = value.quantize(
#             Decimal('.01'),
#             rounding=ROUND_HALF_UP
#         )
#         negative = value < 0
#         value = abs(value)
#         integer, fraction = divmod(value, 1)
#         integer = int(integer)
#         cents = int(fraction * 100)
# 
#     return integer, cents, negative
# 
# def prefix_currency(prefix, base):
#     return tuple("%s %s" % (prefix, i) for i in base)


import math
from collections import OrderedDict
from decimal import Decimal
from .compat import to_s
from .currency import parse_currency_parts, prefix_currency

        post = abs(value - pre) * 10**self.precision
        if abs(round(post) - post) < 0.01:
            # We generally floor all values beyond our precision (rather than
            # rounding), but in cases where we have something like 1.239999999,
            # which is probably due to python's handling of floats, we actually
            # want to consider it as 1.24 instead of 1.23
            post = int(round(post))
        else:
            post = int(math.floor(post))

        return pre, post

    def to_cardinal_float(self, value):
        try:
            float(value) == value
        except (ValueError, TypeError, AssertionError, AttributeError):
            raise TypeError(self.errmsg_nonnum % value)

        pre, post = self.float2tuple(float(value))

        post = str(post)
        post = '0' * (self.precision - len(post)) + post

        out = [self.to_cardinal(pre)]
        if self.precision:
            out.append(self.title(self.pointword))

        for i in range(self.precision):
            curr = int(post[i])

# Path: num2words/compat.py
# def to_s(val):
#     try:
#         return unicode(val)
#     except NameError:
#         return str(val)
# 
# Path: num2words/currency.py
# def parse_currency_parts(value, is_int_with_cents=True):
#     if isinstance(value, int):
#         if is_int_with_cents:
#             # assume cents if value is integer
#             negative = value < 0
#             value = abs(value)
#             integer, cents = divmod(value, 100)
#         else:
#             negative = value < 0
#             integer, cents = abs(value), 0
# 
#     else:
#         value = Decimal(value)
#         value = value.quantize(
#             Decimal('.01'),
#             rounding=ROUND_HALF_UP
#         )
#         negative = value < 0
#         value = abs(value)
#         integer, fraction = divmod(value, 1)
#         integer = int(integer)
#         cents = int(fraction * 100)
# 
#     return integer, cents, negative
# 
# def prefix_currency(prefix, base):
#     return tuple("%s %s" % (prefix, i) for i in base)


# Path: num2words/base.py
import math
from collections import OrderedDict
from decimal import Decimal
from .compat import to_s
from .currency import parse_currency_parts, prefix_currency


        post = abs(value - pre) * 10**self.precision
        if abs(round(post) - post) < 0.01:
            # We generally floor all values beyond our precision (rather than
            # rounding), but in cases where we have something like 1.239999999,
            # which is probably due to python's handling of floats, we actually
            # want to consider it as 1.24 instead of 1.23
            post = int(round(post))
        else:
            post = int(math.floor(post))

        return pre, post

    def to_cardinal_float(self, value):
        try:
            float(value) == value
        except (ValueError, TypeError, AssertionError, AttributeError):
            raise TypeError(self.errmsg_nonnum % value)

        pre, post = self.float2tuple(float(value))

        post = str(post)
        post = '0' * (self.precision - len(post)) + post

        out = [self.to_cardinal(pre)]
        if self.precision:
            out.append(self.title(self.pointword))

        for i in range(self.precision):
            curr = int(post[i])

            out.append(to_s(self.to_cardinal(curr)))