Product Documentation

c-treeDB API for C# - Developers Guide

Previous Topic

Next Topic

CTNUMBER

CTNUMBER corresponds to a number with a given precision (maximum number of digits) and scale (the number of digits to the right of the decimal point). Numeric values can have maximum values of 32 digits precision and scale of 0 (this is 99999999999999999999999999999999), which can represent very large exact values.

c-treeDB .NET provides the class CTNumber that exposes the following set of methods to manipulate this very powerful number representation.

Method

Operation

AsMoney()

Convert CTNUMBER to CTMONEY.

AsLong()

Convert CTNUMBER to LONG.

AsBigint()

Convert CTNUMBER to CTBIGINT.

AsCurrency()

Convert CTNUMBER to CTCURRENCY.

AsFloat()

Convert CTNUMBER to CTFLOAT.

AsString()

Convert CTNUMBER to string.

Zero()

Set the value pointed by pNumber to zero.

IsZero()

Return true if the value is zero.

Round()

Round the value pointer by num to the number of decimal digits (digits to the right of the decimal point) indicated by scale.

DecimalDigits()

Given the CTNUMBER data, stores the number of digits to the left of the decimal point in digit_before and stores the number of digits to the right of decimal point in digit_after.

Also, C# overrides operators (such as +, -, *, and /) so that the result returned is the same type as the items operated upon. For example, the following command would put the result in c as type CTNumber. In C#, comparison operators can be used for any CT types; the return is a Boolean indicating true or false.

c = (CTNumber) a + (CTNumber) b;

TOCIndex