Table of Contents

Interface IFixedPointAmount

Namespace
Virtufin.Core.Position
Assembly
Virtufin.Core.dll

A fixed-point amount: a value stored as a whole part and a fractional part interpreted in a given Base with Precision fractional digits. The represented value is Whole + Fraction / Base^Precision, or equivalently ToCardinal() / Base^Precision.

public interface IFixedPointAmount : IAmount
Inherited Members

Remarks

Base and precision are part of the value's identity: equality, ordering, and addition/subtraction across differing base or precision are rejected (see PrecisionMismatchException). Multiplication/division across differing base or precision are supported through FixedPointArithmetic, which takes an explicit result scale.

Properties

Base

Radix of the fractional representation (e.g. 10 or 2). Always >= 2.

int Base { get; }

Property Value

int

Fraction

The fractional part, a magnitude in [0, Base^Precision).

ulong Fraction { get; }

Property Value

ulong

Whole

The whole (integral) part.

long Whole { get; }

Property Value

long

Methods

ToCardinal()

The value as a single checked integer scaled by Base^Precision: Whole * Base^Precision + Fraction.

long ToCardinal()

Returns

long