System.MulDivInt64

From Appmethod Libraries
Jump to: navigation, search

Object Pascal

function MulDivInt64(AValue, AMul, ADiv: Int64; [out Remainder: Int64]): Int64; overload;
function MulDivInt64(AValue, AMul, ADiv: Int64; [out Remainder: Int64]): Int64; overload;

Properties

Type Visibility Source Unit Parent
function public System.pas System System

Description

Returns the value of this expression: Int64((Int128(AValue) * Int128(AMul)) div Int128(ADiv)).

  • Int128 is a pseudo type thet represents a signed 128-bit integer value.
  • If you specify the optional parameter <Remainder>, this parameter stores the result value of the following expression: Int64((Int128(AValue) * Int128(AMul)) mod Int128(ADiv)).

In the expression A * B div C, if A * B overflows, the result is invalid. This function calculates the values in 128-bit integer as a workaround for the potential overflow.

See Also