Skip to content

Modern Finance AddScaled

Paul Squires edited this page Oct 19, 2026 · 5 revisions

Home › Finance › Finance › AddScaled

AddScaled

Adds an amount times a fraction, such as one third, to a running total exactly.

Syntax

CurrencyAccum.AddScaled( byref c as Currency, byval num as int64, byval den as int64 )

Notes

  • A rational factor rather than a double one, so a third of an amount is exact instead of being 0.3333333333333333 of it.
  • The multiplication happens in 128 bits before the division, so neither the product nor the quotient loses a unit.
  • The shape for splitting an amount by shares, or applying a rate that is naturally a fraction.

Examples

#import "std/money"
using money

dim acc as CurrencyAccum
dim as Currency total_ = CurrencyFromInt( 100 )

'' Exactly one third, three times -- not 0.3333... three times
for i as int32 = 1 to 3
    acc.AddScaled( total_, 1, 3 )
next

print acc.Total( ).ToString( )                '' 100.0000

Library: Finance
Category: Finance
Documented under: Members

Clone this wiki locally