diff --git a/mdbook/src/Chapters/Conversions.md b/mdbook/src/Chapters/Conversions.md
index 9b3060c..7fbd25f 100644
--- a/mdbook/src/Chapters/Conversions.md
+++ b/mdbook/src/Chapters/Conversions.md
@@ -17,16 +17,18 @@ The `frac [base]` command takes the item on the top of the stack (`line1`) and d
if `frac 5` would have been entered (which means 1/5 is maximum granularity), you get `1.1234 is approximately 1 1/5`.
-|
Command
|Description|
-|-------|-----------|
-|to%|Converts `line1` from a "number" to a percent. For example, `0.4455` becomes `44.55%`. This is simply done by multiplying the number by 100|
-|from%|Converts `line1` from a percent to a "number". For example, `93.124%` becomes `.93124`. This is simply done by multiplying the number by 0.01|
-|frac [base]|Display a fractional estimate of the last stack item (`line1`) with the maximum granularity of 1/[base]. See the above description for more detail|
-|in2mm|Converts the value in `line1` from inches to millimeters|
-|mm2in|Converts the value in `line1` from millimeters to inches|
-|deg2rad|Convert `line1` from degrees into [radians](https://en.wikipedia.org/wiki/Radian)|
-|rad2deg|Convert `line1` from radians into degrees|
-|gram2oz
grams2oz|Convert `line1` from grams into ounces using the constant of 0.035274 ounces / gram|
-|oz2gram
oz2grams|Convert `line1` from ounces into grams using the constant of 28.349523125 grams / ounce|
-|kg2lbs
kgs2lbs|convert `line1` from kilograms to US pounds using the constant of 2.2046226218 lbs/kg|
-|lbs2kg
lbs2kgs|convert `line1` from US pounds using the constant of 0.45359237 kg/lbs|
+| Command
| Description |
+|---------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------|
+| to% | Converts `line1` from a "number" to a percent. For example, `0.4455` becomes `44.55%`. This is simply done by multiplying the number by 100 |
+| from% | Converts `line1` from a percent to a "number". For example, `93.124%` becomes `.93124`. This is simply done by multiplying the number by 0.01 |
+| frac [base] | Display a fractional estimate of the last stack item (`line1`) with the maximum granularity of 1/[base]. See the above description for more detail |
+| in2mm | Converts the value in `line1` from inches to millimeters |
+| mm2in | Converts the value in `line1` from millimeters to inches |
+| in2ft | Converts the value in `line1` from inches to feet |
+| ft2in | Converts the value in `line1` from feet to inches |
+| deg2rad | Convert `line1` from degrees into [radians](https://en.wikipedia.org/wiki/Radian) |
+| rad2deg | Convert `line1` from radians into degrees |
+| gram2oz
grams2oz | Convert `line1` from grams into ounces using the constant of 0.035274 ounces / gram |
+| oz2gram
oz2grams | Convert `line1` from ounces into grams using the constant of 28.349523125 grams / ounce |
+| kg2lbs
kgs2lbs | convert `line1` from kilograms to US pounds using the constant of 2.2046226218 lbs/kg |
+| lbs2kg
lbs2kgs | convert `line1` from US pounds using the constant of 0.45359237 kg/lbs |
diff --git a/pom.xml b/pom.xml
index ae6e3c4..8a62836 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
org.fross
rpncalc
- 5.2.5
+ 5.2.6
jar
rpncalc
@@ -113,7 +113,7 @@
org.apache.maven.plugins
maven-shade-plugin
- 3.5.2
+ 3.5.3
package
@@ -273,7 +273,7 @@
org.junit.jupiter
junit-jupiter
- 5.10.2
+ 5.11.0-M1
test
@@ -281,7 +281,7 @@
org.jline
jline-reader
- 3.25.1
+ 3.26.1
@@ -289,7 +289,7 @@
org.jline
jline-terminal-jansi
- 3.25.1
+ 3.26.1
diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml
index 6450114..bd37ea2 100644
--- a/snap/snapcraft.yaml
+++ b/snap/snapcraft.yaml
@@ -1,5 +1,5 @@
name: rpncalc
-version: '5.2.5'
+version: '5.2.6'
summary: The command line Reverse Polish Notation (RPN) calculator
description: |
RPNCalc is an easy to use command line based Reverse Polish
diff --git a/src/main/java/org/fross/rpncalc/CommandParser.java b/src/main/java/org/fross/rpncalc/CommandParser.java
index 79c8ea4..a9436ac 100644
--- a/src/main/java/org/fross/rpncalc/CommandParser.java
+++ b/src/main/java/org/fross/rpncalc/CommandParser.java
@@ -222,12 +222,22 @@ public static void Parse(StackObj calcStack, StackObj calcStack2, String cmdInpu
// Convert inches to millimeters
case "in2mm":
- StackConversions.cmdConvertIN2MM(calcStack);
+ StackConversions.cmdIn2Mm(calcStack);
break;
// Convert millimeters to inches
case "mm2in":
- StackConversions.cmdConvertMM2IN(calcStack);
+ StackConversions.cmdMm2In(calcStack);
+ break;
+
+ // Convert inches to feet
+ case "in2ft":
+ StackConversions.cmdIn2Ft(calcStack);
+ break;
+
+ // Convert feet to inches
+ case "ft2in":
+ StackConversions.cmdFt2In(calcStack);
break;
// Convert to Radians
diff --git a/src/main/java/org/fross/rpncalc/Help.java b/src/main/java/org/fross/rpncalc/Help.java
index 73348fd..45b618f 100644
--- a/src/main/java/org/fross/rpncalc/Help.java
+++ b/src/main/java/org/fross/rpncalc/Help.java
@@ -104,6 +104,8 @@ public static void Display() {
Output.printColorln(Ansi.Color.WHITE, " rad2deg Convert line1 from radians to degrees");
Output.printColorln(Ansi.Color.WHITE, " in2mm Convert line1 from inches into millimeters");
Output.printColorln(Ansi.Color.WHITE, " mm2in Convert line1 from millimeters to inches");
+ Output.printColorln(Ansi.Color.WHITE, " in2ft Convert line1 from inches into feet");
+ Output.printColorln(Ansi.Color.WHITE, " ft2in Convert line1 from feet to inches");
Output.printColorln(Ansi.Color.WHITE, " gram2oz Convert line1 from grams to US ounces");
Output.printColorln(Ansi.Color.WHITE, " oz2gram Convert line1 from US ounces to grams");
Output.printColorln(Ansi.Color.WHITE, " kg2lbs Convert line1 from kilograms to US pounds");
diff --git a/src/main/java/org/fross/rpncalc/StackConversions.java b/src/main/java/org/fross/rpncalc/StackConversions.java
index 5d0dfca..ab0ded3 100644
--- a/src/main/java/org/fross/rpncalc/StackConversions.java
+++ b/src/main/java/org/fross/rpncalc/StackConversions.java
@@ -75,9 +75,9 @@ public static void cmdToPercent(StackObj calcStack) {
}
/**
- * cmdConvertMM(): Assumes Line1 is in inches and converts to millimeters
+ * cmdConvertIn2Mm(): Assumes Line1 is in inches and converts to millimeters
*/
- public static void cmdConvertIN2MM(StackObj calcStack) {
+ public static void cmdIn2Mm(StackObj calcStack) {
// Verify at least one elements exists
if (calcStack.isEmpty()) {
Output.printColorln(Ansi.Color.RED, "Error: There must be at least 1 element on the stack to convert");
@@ -92,9 +92,9 @@ public static void cmdConvertIN2MM(StackObj calcStack) {
}
/**
- * cmdConvertIN(): Assumes Line1 is in millimeters and converts to inches
+ * cmdConvertMm2In(): Assumes Line1 is in millimeters and converts to inches
*/
- public static void cmdConvertMM2IN(StackObj calcStack) {
+ public static void cmdMm2In(StackObj calcStack) {
// Verify at least one elements exists
if (calcStack.isEmpty()) {
Output.printColorln(Ansi.Color.RED, "Error: There must be at least 1 element on the stack to convert");
@@ -108,6 +108,40 @@ public static void cmdConvertMM2IN(StackObj calcStack) {
calcStack.push(calcStack.pop().divide(new BigDecimal("25.4"), MathContext.DECIMAL128));
}
+ /**
+ * cmdConvertIn2Ft(): Assumes Line1 is in inches and converts to feet
+ */
+ public static void cmdIn2Ft(StackObj calcStack) {
+ // Verify at least one elements exists
+ if (calcStack.isEmpty()) {
+ Output.printColorln(Ansi.Color.RED, "Error: There must be at least 1 element on the stack to convert");
+ return;
+ }
+
+ // Save current calcStack to the undoStack
+ calcStack.saveUndo();
+
+ // Pop off the last value, convert, and push it back
+ calcStack.push(calcStack.pop().divide(new BigDecimal("12"), MathContext.DECIMAL128));
+ }
+
+ /**
+ * cmdConvertFt2In(): Assumes Line1 is in feet and converts to inches
+ */
+ public static void cmdFt2In(StackObj calcStack) {
+ // Verify at least one elements exists
+ if (calcStack.isEmpty()) {
+ Output.printColorln(Ansi.Color.RED, "Error: There must be at least 1 element on the stack to convert");
+ return;
+ }
+
+ // Save current calcStack to the undoStack
+ calcStack.saveUndo();
+
+ // Pop off the last value, convert, and push it back
+ calcStack.push(calcStack.pop().multiply(new BigDecimal("12")));
+ }
+
/**
* cmdFraction(): Display the last stack item as a fraction with a minimum base of the provided number. For example, sending
* 64 would produce a fraction of 1/64th but will be reduced if possible.
diff --git a/src/test/java/org/fross/rpncalc/StackConversionsTest.java b/src/test/java/org/fross/rpncalc/StackConversionsTest.java
index 35ebbdb..810638a 100644
--- a/src/test/java/org/fross/rpncalc/StackConversionsTest.java
+++ b/src/test/java/org/fross/rpncalc/StackConversionsTest.java
@@ -92,39 +92,39 @@ void testCmdToPercent() {
}
/**
- * Test method for {@link org.fross.rpncalc.StackConversions#cmdConvertIN2MM(org.fross.rpncalc.StackObj)}.
+ * Test method for {@link org.fross.rpncalc.StackConversions#cmdIn2Mm(org.fross.rpncalc.StackObj)}.
*/
@Test
void testCmdConvertIN2MM() {
StackObj stk = new StackObj();
stk.push(31.6);
- StackConversions.cmdConvertIN2MM(stk);
+ StackConversions.cmdIn2Mm(stk);
assertEquals(802.64, stk.peek().doubleValue());
assertEquals(1, stk.size());
stk.push(1.234e12);
- StackConversions.cmdConvertIN2MM(stk);
+ StackConversions.cmdIn2Mm(stk);
assertEquals("3.13436E+13", stk.peek().toString());
assertEquals(2, stk.size());
}
/**
- * Test method for {@link org.fross.rpncalc.StackConversions#cmdConvertMM2IN(org.fross.rpncalc.StackObj)}.
+ * Test method for {@link org.fross.rpncalc.StackConversions#cmdMm2In(org.fross.rpncalc.StackObj)}.
*/
@Test
void testCmdConvertMM2IN() {
StackObj stk = new StackObj();
stk.push(666.0);
- StackConversions.cmdConvertMM2IN(stk);
+ StackConversions.cmdMm2In(stk);
StackCommands.cmdRound(stk, "4");
assertEquals(26.2205, stk.peek().doubleValue());
assertEquals(1, stk.size());
stk.push(1.234e12);
- StackConversions.cmdConvertMM2IN(stk);
+ StackConversions.cmdMm2In(stk);
StackCommands.cmdRound(stk, "10");
assertEquals("48582677165.3543307087", stk.peek().toEngineeringString());
assertEquals(2, stk.size());
@@ -498,4 +498,40 @@ void testLbs2Kg() {
assertEquals("1959972630770000000.00", stk.pop().toEngineeringString());
}
+ /**
+ * Test Inches to Feet conversion
+ */
+ @Test
+ void testIn2Ft() {
+ StackObj stk = new StackObj();
+
+ stk.push(123.321);
+ StackConversions.cmdIn2Ft(stk);
+ StackCommands.cmdRound(stk, "5");
+ assertEquals(10.27675, stk.pop().doubleValue());
+
+ stk.push(-50.987654);
+ StackConversions.cmdIn2Ft(stk);
+ StackCommands.cmdRound(stk, "5");
+ assertEquals(-4.24897, stk.pop().doubleValue());
+ }
+
+ /**
+ * Test Feet to Inches conversion
+ */
+ @Test
+ void testFt2In() {
+ StackObj stk = new StackObj();
+
+ stk.push(7117.44);
+ StackConversions.cmdFt2In(stk);
+ StackCommands.cmdRound(stk, "5");
+ assertEquals(85409.28, stk.pop().doubleValue());
+
+ stk.push(-32.0011);
+ StackConversions.cmdFt2In(stk);
+ StackCommands.cmdRound(stk, "5");
+ assertEquals(-384.0132, stk.pop().doubleValue());
+ }
+
}