Skip to content

Modern Finance DecimalCompare

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

Home › Finance › Finance › DecimalCompare

DecimalCompare

Returns -1, 0 or 1 comparing two Decimals by value, or -2 if either is Invalid.

Syntax

DecimalCompare( a, b )

Examples

#import "std/money"
using money

'' -1, 0 or +1, blind to the scale: 1.10 and 1.1 are the same number
print DecimalCompare( DecimalParse( "1.10" ).Value( ), _
                      DecimalParse( "1.1" ).Value( ) )    '' 0
print DecimalCompare( DecimalParse( "1" ).Value( ), _
                      DecimalParse( "2" ).Value( ) )      '' -1

'' -2 means one of them was Invalid.  It is deliberately NOT -1, so a
'' caller that forgets to check cannot mistake it for 'less than'
print DecimalCompare( DecimalInvalid( ), DecimalOne( ) )   '' -2

Library: Finance
Category: Finance
Documented under: Nothing Becomes A Keyword

Clone this wiki locally