src/main/java/com/xdavide9/calculatorfx/CalculatorFXController.java
@FXML
    protected void onInstantOperationPressed(ActionEvent e) {
        id = updateId(e);
        log.info("Pressed: {}", id);

        //error checking
        onLabel = label.getText();
        if (status(onLabel) == -1) return;

        BigDecimal value = new BigDecimal(onLabel);

        switch (id) {
            case "toThePowerOfTwoButton" -> value = value.pow(2);
            case "radicalTwoButton" ->  {
                if (value.doubleValue() < 0.0) {
                    log.error("Cannot extract square root of a negative number");
                    displayErr();
                    return;
                }
                value = value.sqrt(new MathContext(15));
            }
            case "percentButton" ->  {
                if (value.doubleValue() < 0.0) {
                    log.error("Cannot calculate percentage off a negative number");
                    displayErr();
                    return;
                }
                value = division(value, BigDecimal.valueOf(100)); //divide by 100
            }
            case "logButton" ->  {
                if (value.doubleValue() <= 0.0 || value.doubleValue() == 1.0) {
                    log.error("invalid argument for this logarithm");
                    displayErr();
                    return;
                }
                value = BigDecimal.valueOf(Math.log10(value.doubleValue()));
            }
            case "lnButton" ->  {
                if (value.doubleValue() <= 0.0 || value.doubleValue() == 1.0) {
                    log.error("invalid argument for this logarithm");
                    displayErr();
                    return;
                }
                value = BigDecimal.valueOf(Math.log(value.doubleValue()));
            }
            case "sinButton" -> value = BigDecimal.valueOf(Math.sin(value.doubleValue()));
            case "cosButton" -> value = BigDecimal.valueOf(Math.cos(value.doubleValue()));
            case "tanButton" -> value = BigDecimal.valueOf(Math.tan(value.doubleValue()));
            case "asinButton" -> {
                if (value.doubleValue() < -1.0 || value.doubleValue() > 1.0) {
                    log.error("Out of arc-sine domain");
                    displayErr();
                    return;
                }
                value = BigDecimal.valueOf(Math.asin(value.doubleValue()));
            }
            case "acosButton" -> {
                if (value.doubleValue() < -1.0 || value.doubleValue() > 1.0) {
                    log.error("Out of arc-cosine domain");
                    displayErr();
                    return;
                }
                value = BigDecimal.valueOf(Math.acos(value.doubleValue()));
            }
            case "atanButton" -> value = BigDecimal.valueOf(Math.atan(value.doubleValue()));
            case "radicalThreeButton" -> value = BigDecimal.valueOf(Math.cbrt(value.doubleValue()));
            case "reciprocalButton" -> {
                if (value.doubleValue() == 0.0) {
                    log.error("Reciprocal of 0 does not exist");
                    displayErr();
                    return;
                }
                value = division(new BigDecimal("1"), value);
            }
            case "factorialButton" -> {
                if (value.toString().contains(".") || value.doubleValue() < 0.0) {
                    log.error("Factorial must a be a positive integer");
                    displayErr();
                    return;
                }
                value = BigDecimal.valueOf(factorial(value.doubleValue()));
            }
        }

        if (value.toString().contains(".")) {
            value = round(value);
        }

        onLabel = String.valueOf(value);
        if (hasTooManyDigits(onLabel.length())) {
            log.error("Result had too many digits");
            displayErr();
            return;
        }

        builder = new StringBuilder();
        builder.append(onLabel);
        label.setText(onLabel);
    }
/**
     * Performs operation on the value being displayed without the need to use memory
     * Currently performed operations:
     * Exponentiation of the second power,
     * Square root extraction,
     * Percentage calculation,
     * Logarithm of base 10,
     * Logarithm of base e,
     * sine function,
     * cosine function ,
     * tangent function,
     * arc-sine function,
     * arc-cosine function,
     * arc-tangent function,
     * root extraction of index 3,
     * reciprocal calculation,
     * factorial function.
     */
Performs operation on the value being displayed without the need to use memory
Currently performed operations:
Exponentiation of the second power,
Square root extraction,
Percentage calculation,
Logarithm of base 10,
Logarithm of base e,
sine function,
cosine function ,
tangent function,
arc-sine function,
arc-cosine function,
arc-tangent function,
root extraction of index 3,
reciprocal calculation,
factorial function.
Performs operation on the value being displayed without the need to use memory Currently performed operations : Exponentiation of the second power Square root extraction Percentage calculation Logarithm of base 10 Logarithm of base e sine function cosine function tangent function arc - sine function arc - cosine function arc - tangent function root extraction of index 3 reciprocal calculation factorial function .
@FXML
    protected void onInstantOperationPressed(ActionEvent e) {
        id = updateId(e);
        log.info("Pressed: {}", id);
        onLabel = label.getText();
        if (status(onLabel) == -1) return;
        BigDecimal value = new BigDecimal(onLabel);
        switch (id) {
            case "toThePowerOfTwoButton" -> value = value.pow(2);
            case "radicalTwoButton" ->  {
                if (value.doubleValue() < 0.0) {
                    log.error("Cannot extract square root of a negative number");
                    displayErr();
                    return;
                }
                value = value.sqrt(new MathContext(15));
            }
            case "percentButton" ->  {
                if (value.doubleValue() < 0.0) {
                    log.error("Cannot calculate percentage off a negative number");
                    displayErr();
                    return;
                }
                value = division(value, BigDecimal.valueOf(100)); 
            }
            case "logButton" ->  {
                if (value.doubleValue() <= 0.0 || value.doubleValue() == 1.0) {
                    log.error("invalid argument for this logarithm");
                    displayErr();
                    return;
                }
                value = BigDecimal.valueOf(Math.log10(value.doubleValue()));
            }
            case "lnButton" ->  {
                if (value.doubleValue() <= 0.0 || value.doubleValue() == 1.0) {
                    log.error("invalid argument for this logarithm");
                    displayErr();
                    return;
                }
                value = BigDecimal.valueOf(Math.log(value.doubleValue()));
            }
            case "sinButton" -> value = BigDecimal.valueOf(Math.sin(value.doubleValue()));
            case "cosButton" -> value = BigDecimal.valueOf(Math.cos(value.doubleValue()));
            case "tanButton" -> value = BigDecimal.valueOf(Math.tan(value.doubleValue()));
            case "asinButton" -> {
                if (value.doubleValue() < -1.0 || value.doubleValue() > 1.0) {
                    log.error("Out of arc-sine domain");
                    displayErr();
                    return;
                }
                value = BigDecimal.valueOf(Math.asin(value.doubleValue()));
            }
            case "acosButton" -> {
                if (value.doubleValue() < -1.0 || value.doubleValue() > 1.0) {
                    log.error("Out of arc-cosine domain");
                    displayErr();
                    return;
                }
                value = BigDecimal.valueOf(Math.acos(value.doubleValue()));
            }
            case "atanButton" -> value = BigDecimal.valueOf(Math.atan(value.doubleValue()));
            case "radicalThreeButton" -> value = BigDecimal.valueOf(Math.cbrt(value.doubleValue()));
            case "reciprocalButton" -> {
                if (value.doubleValue() == 0.0) {
                    log.error("Reciprocal of 0 does not exist");
                    displayErr();
                    return;
                }
                value = division(new BigDecimal("1"), value);
            }
            case "factorialButton" -> {
                if (value.toString().contains(".") || value.doubleValue() < 0.0) {
                    log.error("Factorial must a be a positive integer");
                    displayErr();
                    return;
                }
                value = BigDecimal.valueOf(factorial(value.doubleValue()));
            }
        }
        if (value.toString().contains(".")) {
            value = round(value);
        }
        onLabel = String.valueOf(value);
        if (hasTooManyDigits(onLabel.length())) {
            log.error("Result had too many digits");
            displayErr();
            return;
        }
        builder = new StringBuilder();
        builder.append(onLabel);
        label.setText(onLabel);
    }
@ FXML protected void onInstantOperationPressed ( ActionEvent e ) { id = updateId ( e ) ; log . info ( "Pressed: {}" , id ) ; onLabel = label . getText ( ) ; if ( status ( onLabel ) == - 1 ) return ; BigDecimal value = new BigDecimal ( onLabel ) ; switch ( id ) { case "toThePowerOfTwoButton" -> value = value . pow ( 2 ) ; case "radicalTwoButton" -> { if ( value . doubleValue ( ) < 0.0 ) { log . error ( "Cannot extract square root of a negative number" ) ; displayErr ( ) ; return ; } value = value . sqrt ( new MathContext ( 15 ) ) ; } case "percentButton" -> { if ( value . doubleValue ( ) < 0.0 ) { log . error ( "Cannot calculate percentage off a negative number" ) ; displayErr ( ) ; return ; } value = division ( value , BigDecimal . valueOf ( 100 ) ) ; } case "logButton" -> { if ( value . doubleValue ( ) <= 0.0 || value . doubleValue ( ) == 1.0 ) { log . error ( "invalid argument for this logarithm" ) ; displayErr ( ) ; return ; } value = BigDecimal . valueOf ( Math . log10 ( value . doubleValue ( ) ) ) ; } case "lnButton" -> { if ( value . doubleValue ( ) <= 0.0 || value . doubleValue ( ) == 1.0 ) { log . error ( "invalid argument for this logarithm" ) ; displayErr ( ) ; return ; } value = BigDecimal . valueOf ( Math . log ( value . doubleValue ( ) ) ) ; } case "sinButton" -> value = BigDecimal . valueOf ( Math . sin ( value . doubleValue ( ) ) ) ; case "cosButton" -> value = BigDecimal . valueOf ( Math . cos ( value . doubleValue ( ) ) ) ; case "tanButton" -> value = BigDecimal . valueOf ( Math . tan ( value . doubleValue ( ) ) ) ; case "asinButton" -> { if ( value . doubleValue ( ) < - 1.0 || value . doubleValue ( ) > 1.0 ) { log . error ( "Out of arc-sine domain" ) ; displayErr ( ) ; return ; } value = BigDecimal . valueOf ( Math . asin ( value . doubleValue ( ) ) ) ; } case "acosButton" -> { if ( value . doubleValue ( ) < - 1.0 || value . doubleValue ( ) > 1.0 ) { log . error ( "Out of arc-cosine domain" ) ; displayErr ( ) ; return ; } value = BigDecimal . valueOf ( Math . acos ( value . doubleValue ( ) ) ) ; } case "atanButton" -> value = BigDecimal . valueOf ( Math . atan ( value . doubleValue ( ) ) ) ; case "radicalThreeButton" -> value = BigDecimal . valueOf ( Math . cbrt ( value . doubleValue ( ) ) ) ; case "reciprocalButton" -> { if ( value . doubleValue ( ) == 0.0 ) { log . error ( "Reciprocal of 0 does not exist" ) ; displayErr ( ) ; return ; } value = division ( new BigDecimal ( "1" ) , value ) ; } case "factorialButton" -> { if ( value . toString ( ) . contains ( "." ) || value . doubleValue ( ) < 0.0 ) { log . error ( "Factorial must a be a positive integer" ) ; displayErr ( ) ; return ; } value = BigDecimal . valueOf ( factorial ( value . doubleValue ( ) ) ) ; } } if ( value . toString ( ) . contains ( "." ) ) { value = round ( value ) ; } onLabel = String . valueOf ( value ) ; if ( hasTooManyDigits ( onLabel . length ( ) ) ) { log . error ( "Result had too many digits" ) ; displayErr ( ) ; return ; } builder = new StringBuilder ( ) ; builder . append ( onLabel ) ; label . setText ( onLabel ) ; }
Performs operation on the value being displayed without the need to use memory
 Currently performed operations:
 Exponentiation of the second power,
 Square root extraction,
 Percentage calculation,
 Logarithm of base 10,
 Logarithm of base e,
 sine function,
 cosine function ,
 tangent function,
 arc-sine function,
 arc-cosine function,
 arc-tangent function,
 root extraction of index 3,
 reciprocal calculation,
 factorial function.
Performs operation on the value being displayed without the need to use memory Currently performed operations : Exponentiation of the second power Square root extraction Percentage calculation Logarithm of base 10 Logarithm of base e sine function cosine function tangent function arc - sine function arc - cosine function arc - tangent function root extraction of index 3 reciprocal calculation factorial function .
//error checking //divide by 100