Skip to content

Calculator settings

maltaisn edited this page Sep 19, 2018 · 7 revisions

Many settings are available to you to change the default behaviour of the calculator. Each method returns the dialog instance to allow method chaining.

  • setMaxValue(@Nullable BigDecimal maxValue): Set the value at which an Out of bounds error is shown.

    • maxValue: Maximum value BigDecimal, use null for no maximum (not recommended). The default maximum is 10,000,000,000 (1e+10). This value is applied both for positive and negative numbers. If you set a maximum value less than the initial value, initial value will become the same as maximum value.
  • setMaxDigits(int intPart, int fracPart): Set the maximum digits that can be entered for each part of a number. CalcDialog.MAX_DIGITS_UNLIMITED can be set for any of the two parameters to allow any number of digits (not recommended).

    • intPart: Maximum digits for the integer part. Must be at least 1. Default is 10.
    • fracPart: Maximum digits for the fractional part. Use 0 to allow no decimals. Default is 8.
  • setRoundingMode(RoundingMode roundingMode): Set the rounding mode for calculations.

    • roundingMode: One value in enum RoundingMode except RoundingMode.UNNECESSARY. Defaut rounding mode is RoundingMode.HALF_UP.
  • setSignCanBeChanged(boolean canBeChanged, int sign):

    • canBeChanged: Whether sign can be changed or not. If true, no value with a wrong sign can be returned and an error will be displayed.
    • sign: If canBeChanged is true, which sign to force, either -1 or 1. Otherwise use any value.
  • setFormatSymbols(char decimalSep, char groupSep): Set the symbols for formatting displayed value. CalcDialog.FORMAT_CHAR_DEFAULT can be set for any of the two parameters to use device's default locale symbols.

    • decimalSep: Decimal separator symbol
    • groupSep: Grouping separator symbol.
  • setClearDisplayOnOperation(boolean clear):

    • clear: Whether to clear display when an operation button is clicked. By default display is not cleared.
  • setShowZeroWhenNoValue(boolean show):

    • show: Whether to display zero when there is no value i.e when initial value is null, when an operation button is clicked, when all digits have been erased and when an error occurs. By default, 0 is displayed.
  • setGroupSize(int size):

    • size: Size of groups separated by group separators. Use 0 for no grouping. By default, group size is 3, i.e: 1,000,000.
  • setShowAnswerButton(boolean show):

    • show: Whether to show answer button or not. By default answer button is not shown. If true, answer button will replace equal button after an operation button is clicked.
  • setShowSignButton(boolean show):

    • show: Whether to show sign button or not. By default answer button is shown.
Clone this wiki locally