Home  |  Delphi .net Home  |  System.Decimal  |  Compare Method
Compare  
Method  
Compares one Decimal value with another
Decimal Structure
System NameSpace
CF1.  Function Compare ( ValueA:DecimalValueA : Decimal; ValueB : Decimal; ) : Integer; Static;
CF : Methods with this mark are Compact Framework Compatible
Description
Compares ValueA with ValueB value.
 
Returns one of the following values :
 
ValueA < ValueB Gives <0
ValueA = ValueB Gives  0
ValueA > ValueB Gives >0

 
The exact value is not guaranteed.
Notes
Static methods are not methods of an object - they are simply class functions or procedures available at any time.
Microsoft MSDN Links
System
System.Decimal
 
 
A simple example
program Project1;
{$APPTYPE CONSOLE}

var
  valueA, valueB : Decimal;
  result         : Integer;

begin
  valueA := 23;
  valueB := 57;

  result := System.Decimal.Compare(valueA, valueB);
  Console.WriteLine('valueA compared to valueB = {0}', result.ToString);

  result := System.Decimal.Compare(valueB, valueB);
  Console.WriteLine('valueB compared to valueB = {0}', result.ToString);

  result := System.Decimal.Compare(valueB, valueA);
  Console.WriteLine('valueB compared to valueA = {0}', result.ToString);

  Console.ReadLine;
end.
Show full unit code
  valueA compared to valueB = -1
  valueB compared to valueB = 0
  valueB compared to valueA = 1
 
 
Delphi Programming © Neil Moffatt All rights reserved.  |  Contact the author