Skip to content

Commit

Permalink
Added addall, delete, and modulus commands to UserGuide
Browse files Browse the repository at this point in the history
  • Loading branch information
frossm committed Nov 18, 2023
1 parent 45db508 commit d403259
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions mdbook/src/Chapters/CalculatorCommands.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ These commands, like the others you'll read about later, are executed by typing

|<div style="width:110px">Command</div>|Description|
|-------|-----------|
|aa [keep]| **ADD ALL**<br>Add all stack items together and replace the numbers on the stack with the result. If the optional `keep` parameter is sent, the elements added will be retained on the stack and the total will be added to the top of the stack. The entire `keep` command is not necessary, anything that starts with `k` will work|
|aa [keep]<br>addall [keep]| **ADD ALL**<br>Add all stack items together and replace the numbers on the stack with the result. If the optional `keep` parameter is sent, the elements added will be retained on the stack and the total will be added to the top of the stack. The entire `keep` command is not necessary, anything that starts with `k` will work|
|abs| **ABSOLUTE VALUE**<br>Takes the [absolute value](https://en.wikipedia.org/wiki/Absolute_value#:~:text=In%20mathematics%2C%20the%20absolute%20value,and%20%7C0%7C%20%3D%200) of line 1. The returns the positive value of the number. Not the most useful command on it's own as you can always `f` flip the sign. However it could be useful as part of a User Defined Function|
|avg [keep]<br>mean [keep]|**AVERAGE / MEAN**<br>Calculate the [average](https://en.wikipedia.org/wiki/Average) of all of the numbers on the stack. The stack will be replaced with the result. If `keep` is provided, the stack will be retained and the average will be added on top. `average` or `mean` can also be used|
|c <br> clear| **CLEAR**<br>Clear the current stack and the screen. Memory data is retained and you can undo the clear with the undo `u` command|
|cl <br> clean| **CLEAN SCREEN**<br>Clear the current screen, but keep the stack. After cleaning, the stack will be displayed at the top of the screen. Used to remove the clutter|
|copy [#] <br> dup [#]|**COPY**<br>With no number provided, copy will duplicate the top stack item / `line1` and place it on the stack. If the optional line number is given, the value at that line will be duplicated to the top of the stack|
|d<br>d [#]<br>d [#-#]| **DELETE**<br>If `d` is given without any parameters, it will delete `line1`. If a line number is given after the `d`, that line number will be deleted. A range can be given as well, such as `d 1-3` and RPNCalc will delete those lines and everything in between. `del` can also be used|
|d<br>d [#]<br>d [#-#]<br>delete [#-#]| **DELETE**<br>If `d` is given without any parameters, it will delete `line1`. If a line number is given after the `d`, that line number will be deleted. A range can be given as well, such as `d 1-3` and RPNCalc will delete those lines and everything in between. `del` can also be used|
|dice XdY<br>roll XdY| **DICE ROLL**<br>Roll a Y sided die X times and add the results to the stack. Default is 1d6 which roll a six sided dice one time. This is a more specific version of `random`. While not a normal calculator function, it's fun! (Especially if you're an old school gamer)|
|fact <br>factorial| **FACTORIAL**<br>Takes the factorial of `line1`. The factorial target number must be an integer, so if there is a decimal component, it will be dropped (not rounded) as with the `int` command|
|f <br> flip | **FLIP SIGN**<br>Flip the sign on the top stack item (`line1`). This is effectively multiplying `line1` by `-1`|
Expand All @@ -27,7 +27,7 @@ These commands, like the others you'll read about later, are executed by typing
|max|**MAXIMUM VALUE**<br>Copies the largest value in the top of the stack (`line1`)|
|median [keep]|**MEDIAN**<br>Replaces the current stack with the [median](https://en.wikipedia.org/wiki/Median) value. For an odd number of stack items, the "middle" value will be used. With an even number of items there is no "middle" value so the two center most values will be averaged. If the `keep` flag is used, the median value will be added on top of the stack retaining the current stack values|
|min|**MINIMUM VALUE**<br>Copies the smallest value of the stack items to the top of the stack (`line1`)|
|mod| **MODULUS / REMAINDER**<br>[Modulus](en.wikipedia.org/wiki/Modular_arithmetic) is the remainder after a division. This command will perform a division of the top two stack items (removing them from the stack) and return the remainder back to the stack. <br>Please note that RPNCalc now uses the BigDecimal [Remainder method](https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html#:~:text=1.5-,remainder,-public%C2%A0BigDecimal%C2%A0remainder(BigDecimal%C2%A0divisor)). This makes the point that remainder is different than modulus. The remainder is given by `subtract(this.divideToIntegralValue(divisor).multiply(divisor))` Note that this is not the modulo operation as the result can be negative|
|mod<br>modulus| **MODULUS / REMAINDER**<br>[Modulus](en.wikipedia.org/wiki/Modular_arithmetic) is the remainder after a division. This command will perform a division of the top two stack items (removing them from the stack) and return the remainder back to the stack. <br>Please note that RPNCalc now uses the BigDecimal [Remainder method](https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html#:~:text=1.5-,remainder,-public%C2%A0BigDecimal%C2%A0remainder(BigDecimal%C2%A0divisor)). This makes the point that remainder is different than modulus. The remainder is given by `subtract(this.divideToIntegralValue(divisor).multiply(divisor))` Note that this is not the modulo operation as the result can be negative|
|rand [low] \[high] | **RANDOM NUMBER GENERATION**<br>Generate a random integer number between the provided `[l]ow` and `[h]igh` numbers inclusive to both. If no numbers are provided, then the random number will be between 1 and 100 inclusive|
|round [n]| **ROUND**<br>Round `line1` to `[n]` decimal places. If `[n]` is not given, round to the nearest integer (zero decimal places). **Example 1:** `3.14159` `round` would round to `3`. **Example 2:** `3.14159` `round 4` would round to `3.1416`|
|s [#] \[#] <br> swap [#] \[#]| **SWAP LINES**<br>Without an argument, swap the top two stack items (`line1 & line2`). You can swap any two line numbers in your stack by providing the two line numbers|
Expand Down

0 comments on commit d403259

Please sign in to comment.