Index: apps/plugins/calculator.c =================================================================== --- apps/plugins/calculator.c (revision 15832) +++ apps/plugins/calculator.c (working copy) @@ -268,7 +268,7 @@ double modifier = 0.1; /* position of next input */ double operand = 0; /* second operand, format 0.xxxxx */ int operandPower = 0; /* 10^power of second operand */ -char oper = ' '; /* operators: + - * / */ +char oper = ' '; /* operators: + - * / ^ */ bool operInputted = false; /* false: do calculation first and replace current oper true: just replace current oper */ @@ -620,7 +620,26 @@ (*operandOne) *= operandTwo; (*powerOne) += powerTwo; } +/* ----------------------------------------------------------------------- +Powers in scientific number format +----------------------------------------------------------------------- */ +void doPower(double* operandOne, int* powerOne, + double operandTwo, int powerTwo) +{ + while(*powerOne > 0){ + (*operandOne) *= 10; + (*powerOne)--; + + } + while(powerTwo > 0){ + (operandTwo) *= 10; + (powerTwo)--; + + } + (*operandOne) = pow((*operandOne),operandTwo); +} + /* ----------------------------------------------------------------------- Handles all one operand calculations ----------------------------------------------------------------------- */ @@ -730,6 +749,9 @@ else calStatus = cal_error; break; + case '^': + doPower(&operand, &operandPower, result, power); + break; default: /* ' ' */ switchOperands(); /* counter switchOperands() below */ break; @@ -1329,8 +1351,19 @@ calStatus = cal_normal; break; - case sci_xy: break; + case sci_xy: + if(!operInputted) {twoOperands(); operInputted = true;} + oper = '^'; +#ifdef CALCULATOR_OPERATORS + case_cycle_operators: /* F2 shortkey entrance */ +#endif + calStatus = cal_normal; + formatResult(); + operand = result; + operandPower = power; + break; + case sci_sci: buttonGroup = basicButtons; printButtonGroups(basicButtons);