cancel
Showing results for 
Search instead for 
Did you mean: 

Reg: compareto method usage in webdynpro

Former Member
0 Kudos

Hi All,

I want to use compareto( ) method in my application. I have two BigDecimal values .How can I compare them and explain the method's functionality clearly...

Thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

check this thread

Message was edited by:

Armin Reichert

Answers (4)

Answers (4)

Former Member
0 Kudos

Thanks all.........

Former Member
0 Kudos

Hi

Use the method compareTo


public int compareTo(BigDecimal val)

Compares this BigDecimal with the specified BigDecimal. Two BigDecimal objects that are equal in value but have a different scale (like 2.0 and 2.00) are considered equal by this method. This method is provided in preference to individual methods for each of the six boolean comparison operators (<, ==, >, >=, !=, <=). The suggested idiom for performing these comparisons is: (x.compareTo(y) <op> 0), where <op> is one of the six comparison operators.

Specified by:

compareTo in interface Comparable<BigDecimal>

Parameters:

val - BigDecimal to which this BigDecimal is to be compared.

Returns:

-1, 0, or 1 as this BigDecimal is numerically less than, equal to, or greater than val.

Thanks

Smitha

former_member485701
Active Participant
0 Kudos

Hi,

You can use following method.

public int compareTo(BigDecimal val);

Ex.BigDecimal val1,val2;

val1.compareTo(BigDecimal val2);

it will return -1, 0, or 1 as this val1 is numerically less than, equal to, or greater than val2.

Regards,

Praveen

Former Member
0 Kudos

Hi,

Use the method public int compareTo(BigDecimal val) Compares this BigDecimal with the specified BigDecimal. Two BigDecimal objects that are equal in value but have a different scale (like 2.0 and 2.00) are considered equal by this method. This method is provided in preference to individual methods for each of the six boolean comparison operators (<, ==, >, >=, !=, <=). The suggested idiom for performing these comparisons is: (x.compareTo(y) <op> 0), where <op> is one of the six comparison operators. @param val BigDecimal to which this BigDecimal is to be compared. @return -1, 0, or 1 as this BigDecimal is numerically less than, equal to, or greater than val.

Regards Ayyapparaj