Gordian Yuan
Gordian Yuan

Reputation: 5040

How to getScale on BigDecimal?

I found BigDecimal have setScale method, but doesn't have getScale method. How to getScale on BigDecimal?

Upvotes: 6

Views: 7448

Answers (3)

gimel
gimel

Reputation: 86362

BigDecimal.scale():

public int scale()

Returns the scale of this BigDecimal. If zero or positive, the scale is the number of digits to the right of the decimal point. If negative, the unscaled value of the number is multiplied by ten to the power of the negation of the scale. For example, a scale of -3 means the unscaled value is multiplied by 1000.

Returns: the scale of this BigDecimal.

Upvotes: 3

Babar
Babar

Reputation: 2826

use BigDecimal.scale()

Upvotes: 1

Gadi
Gadi

Reputation: 482

You have the scale() (not getScale in this case) method in BigDecimal which returns the scale set by setScale(..). See: http://java.sun.com/j2se/1.5.0/docs/api/java/math/BigDecimal.html#scale()

Upvotes: 9

Related Questions