Data.FmtBcd.TBcd

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

  TBcd  = record
    Precision: Byte;                        { 1..64 }
    SignSpecialPlaces: Byte;                { Sign:1, Special:1, Places:6 }
    Fraction: packed array [0..31] of Byte; { BCD Nibbles, 00..99 per Byte, high Nibble 1st }
    class operator Implicit(const str: string): TBcd;
    class operator Implicit(const d: double): TBcd;
    class operator Implicit(const I: Integer): TBcd;
    class operator Explicit(const ABcd: TBcd): string;
    class operator Explicit(const ABcd: TBcd): Integer;
    class operator Add(const A, B: TBcd): TBcd;
    class operator Subtract(const A, B: TBcd): TBcd;
    class operator Multiply(const A, B: TBcd): TBcd;
    class operator Divide(const A, B: TBcd): TBcd;
    class operator Negative(const A: TBcd): TBcd;
    class operator Equal(const A, B: TBcd): Boolean;
    class operator NotEqual(const A, B: TBcd): Boolean;
    class operator GreaterThan(const A, B: TBcd): Boolean;
    class operator LessThan(const A, B: TBcd): Boolean;
    class operator GreaterThanOrEqual(const A, B: TBcd): Boolean;
    class operator LessThanOrEqual(const A, B: TBcd): Boolean;
  end;

C++

struct DECLSPEC_DRECORD TBcd
{
public:
    System::Byte Precision;
    System::Byte SignSpecialPlaces;
    System::StaticArray<System::Byte, 32> Fraction;
    static TBcd __fastcall _op_Implicit(const System::UnicodeString str);
    static TBcd __fastcall _op_Implicit(const double d);
    static TBcd __fastcall _op_Implicit(const int I);
    static TBcd __fastcall _op_Addition(const TBcd &A, const TBcd &B);
    static TBcd __fastcall _op_Subtraction(const TBcd &A, const TBcd &B);
    static TBcd __fastcall _op_Multiply(const TBcd &A, const TBcd &B);
    static TBcd __fastcall _op_Division(const TBcd &A, const TBcd &B);
    static TBcd __fastcall _op_UnaryNegation(const TBcd &A);
    static bool __fastcall _op_Equality(const TBcd &A, const TBcd &B);
    static bool __fastcall _op_Inequality(const TBcd &A, const TBcd &B);
    static bool __fastcall _op_GreaterThan(const TBcd &A, const TBcd &B);
    static bool __fastcall _op_LessThan(const TBcd &A, const TBcd &B);
    static bool __fastcall _op_GreaterThanOrEqual(const TBcd &A, const TBcd &B);
    static bool __fastcall _op_LessThanOrEqual(const TBcd &A, const TBcd &B);
    TBcd& operator =(const System::UnicodeString str) { *this = TBcd::_op_Implicit(str); return *this; }
    TBcd& operator =(const double d) { *this = TBcd::_op_Implicit(d); return *this; }
    TBcd& operator =(const int I) { *this = TBcd::_op_Implicit(I); return *this; }
    friend TBcd operator +(const TBcd &A, const TBcd &B) { return TBcd::_op_Addition(A, B); }
    friend TBcd operator -(const TBcd &A, const TBcd &B) { return TBcd::_op_Subtraction(A, B); }
    friend TBcd operator *(const TBcd &A, const TBcd &B) { return TBcd::_op_Multiply(A, B); }
    friend TBcd operator /(const TBcd &A, const TBcd &B) { return TBcd::_op_Division(A, B); }
    TBcd operator -() { return TBcd::_op_UnaryNegation(*this); }
    friend bool operator ==(const TBcd &A, const TBcd &B) { return TBcd::_op_Equality(A, B); }
    friend bool operator !=(const TBcd &A, const TBcd &B) { return TBcd::_op_Inequality(A, B); }
    friend bool operator >(const TBcd &A, const TBcd &B) { return TBcd::_op_GreaterThan(A, B); }
    friend bool operator <(const TBcd &A, const TBcd &B) { return TBcd::_op_LessThan(A, B); }
    friend bool operator >=(const TBcd &A, const TBcd &B) { return TBcd::_op_GreaterThanOrEqual(A, B); }
    friend bool operator <=(const TBcd &A, const TBcd &B) { return TBcd::_op_LessThanOrEqual(A, B); }
};

Properties

Type Visibility Source Unit Parent
record
struct
public
Data.FmtBcd.pas
Data.FMTBcd.hpp
Data.FmtBcd Data.FmtBcd

Description

TBcd stores a binary coded decimal value.

TBcd represents a binary-coded decimal value. It contains the following fields:

Field Contents

Precision

The number of digits in the decimal version of the value.

SignSpecialPlaces

  • The sign bit (0 is positive, any other value negative)
  • The special bit (nonzero indicates that the value is blank)
  • The number of digits after the decimal (0 to Precision)

Fraction

An array of BCD nibbles, 00 to 99 per byte, high nibble first. Only the first Precision nibbles are used.

You can create a Variant that represents a TBcd value using the Data.FmtBcd.VarFMTBcdCreate function. In fact, the easiest way to manipulate TBcd values is to create Variants for them and use the built-in operators provided by the Variant type.

See Also