From 1cb3c8023b303e68367843ca8fae047e5cfeba5c Mon Sep 17 00:00:00 2001 From: cameyo42 Date: Tue, 14 Nov 2017 14:43:40 +0100 Subject: [PATCH] revision --- complex.pde | 7 +++---- drawGUI.pde | 21 --------------------- fibo.pde | 12 ++++++++---- functionForth.pde | 4 ++-- functionInput.pde | 2 +- time.pde | 2 +- vector.pde | 2 -- 7 files changed, 15 insertions(+), 35 deletions(-) diff --git a/complex.pde b/complex.pde index 458f96e..f81b170 100644 --- a/complex.pde +++ b/complex.pde @@ -55,7 +55,7 @@ void fnCXSUB() isResult = true; isBlocked = false; } - else { outputSTR = "Complex suctraction: four numbers required."; } + else { outputSTR = "Complex subtraction: four numbers required."; } } // sottrazione di due numeri complessi double[] CXSUB(double re1, double im1, double re2, double im2) @@ -132,6 +132,7 @@ void fnCXDIV() } else { outputSTR = "Complex division: four numbers required."; } } + // divisione di due numeri complessi double[] CXDIV(double re1, double im1, double re2, double im2) { @@ -162,7 +163,7 @@ void fnCXINV() { pila.push(re1); digitNUM = im1; - outputSTR = "Complex inverse: 0+i0 does not have a reciprocal."; + outputSTR = "Complex inverse: 0 + i0 does not have a reciprocal."; isResult = true; isBlocked = false; } @@ -264,5 +265,3 @@ double[] CXPOW(double re1, double im1, int n) double[] result = { re, im }; return(result); } - -//double CX \ No newline at end of file diff --git a/drawGUI.pde b/drawGUI.pde index 90aed60..3aa99ec 100644 --- a/drawGUI.pde +++ b/drawGUI.pde @@ -1,4 +1,3 @@ - void drawLCD() { image(lcd_IMG, 0, 0); @@ -40,26 +39,6 @@ void drawOutput() text(outputSTR, 300, 349); } -//void setNumberFormat(int num) -//{ -// switch(num) -// { -// case 0: df = new DecimalFormat("#,##0E0"); break; -// case 1: df = new DecimalFormat("#,##0.0E0"); break; -// case 2: df = new DecimalFormat("#,##0.00E0"); break; -// case 3: df = new DecimalFormat("#,##0.000E0"); break; -// case 4: df = new DecimalFormat("#,##0.0000E0"); break; -// case 5: df = new DecimalFormat("#,##0.00000E0"); break; -// case 6: df = new DecimalFormat("#,##0.000000E0"); break; -// case 7: df = new DecimalFormat("#,##0.0000000E0"); break; -// case 8: df = new DecimalFormat("#,##0.00000000E0"); break; -// case 9: df = new DecimalFormat("#,##0.000000000E0"); break; -// case 10: df = new DecimalFormat("#,##0.0000000000E0"); break; -// case 11: df = new DecimalFormat("#,##0.00000000000E0"); break; -// case 12: df = new DecimalFormat("#,##0.000000000000E0"); break; -// } -//} - String formatNumber(double n) { String numStr; diff --git a/fibo.pde b/fibo.pde index 2b3c0b8..6c2988f 100644 --- a/fibo.pde +++ b/fibo.pde @@ -6,11 +6,13 @@ * https://www.nayuki.io/page/fast-fibonacci-algorithms * adapted by cameyo for ForthCalc.pde (processing) */ - private static BigInteger fastFibonacciDoubling(int n) { + private static BigInteger fastFibonacciDoubling(int n) + { BigInteger a = BigInteger.ZERO; BigInteger b = BigInteger.ONE; int m = 0; - for (int bit = Integer.highestOneBit(n); bit != 0; bit >>>= 1) { + for (int bit = Integer.highestOneBit(n); bit != 0; bit >>>= 1) + { // Loop invariant: a = F(m), b = F(m+1) // Double it BigInteger d = multiply(a, b.shiftLeft(1).subtract(a)); @@ -19,7 +21,8 @@ b = e; m *= 2; // Advance by one conditionally - if ((n & bit) != 0) { + if ((n & bit) != 0) + { BigInteger c = a.add(b); a = b; b = c; @@ -31,6 +34,7 @@ // Multiplies two BigIntegers. // This function makes it easy to swap in a faster algorithm like Karatsuba multiplication. - private static BigInteger multiply(BigInteger x, BigInteger y) { + private static BigInteger multiply(BigInteger x, BigInteger y) + { return x.multiply(y); } \ No newline at end of file diff --git a/functionForth.pde b/functionForth.pde index 081837e..5c42adc 100644 --- a/functionForth.pde +++ b/functionForth.pde @@ -16,7 +16,7 @@ // 2tuck (a b c d -- c d a b c d) Copy the top couple of value below the second couple of value. // pick ( xu...x1 x0 u -- xu...x1 x0 xu ) Remove u. Copy the xu to the top of the stack. Num items >= u+2. -// roll ( xu xu-1 ... x0 u -- xu-1 ... x0 xu ) Remove u. Rotate u+1 items on the top of the stack.Num items > u+2. +// roll ( xu xu-1 ... x0 u -- xu-1 ... x0 xu ) Remove u. Rotate u+1 items on the top of the stack. Num items > u+2. //-------------------------------------------------------------------------- // DUP (a -- a a) Duplica il valore in cima alla pila @@ -431,7 +431,7 @@ void fnRUPS() else { outputSTR = "R UP: at least two numbers required."; } } -// Rotate Up the stack by N items (BUG: negative roll) +// Rotate Up the stack by N items void fnROLLS() { int idx = (int) digitNUM; diff --git a/functionInput.pde b/functionInput.pde index 08721cd..858ada7 100644 --- a/functionInput.pde +++ b/functionInput.pde @@ -12,7 +12,7 @@ void fnFIX() digitRESET = "0." + nf(0, numFloating); fnDROP(); } - else { outputSTR = "FIX: integer number required [-1, 9]"; } + else { outputSTR = "FIX: integer number required [-2, 9]"; } } void enterPressed() diff --git a/time.pde b/time.pde index feadab9..8379c1a 100644 --- a/time.pde +++ b/time.pde @@ -89,7 +89,7 @@ void fnTADD() //println(res$); double res = Double.valueOf(res$); //println(res); -// For example, the result of TIME('11:02:26') - '00:32:56' is 102930 (a duration of 10 hours, 29 minutes, and 30 seconds). + //Example, the result of TIME('11:02:26') - '00:32:56' is 102930 (a duration of 10 hours, 29 minutes, and 30 seconds). digitNUM = res; outputSTR = String.valueOf(digitNUM); isResult = true; diff --git a/vector.pde b/vector.pde index 9039378..16f1dba 100644 --- a/vector.pde +++ b/vector.pde @@ -198,5 +198,3 @@ void fnVECMAG() } else { outputSTR = "Vector3D Magnitude and Heading: three numbers required."; } } - -