diff --git a/data/com.github.subhadeepjasu.pebbles.appdata.xml.in b/data/com.github.subhadeepjasu.pebbles.appdata.xml.in
index 2c7f5f84..bf27200d 100644
--- a/data/com.github.subhadeepjasu.pebbles.appdata.xml.in
+++ b/data/com.github.subhadeepjasu.pebbles.appdata.xml.in
@@ -93,6 +93,18 @@
none
+
+
+ Improved:
+
+ - [Programmer] Transition to integer-integer logic for all operations
+
+ Translations:
+
+ - Simplified Chinese (by Tommy He)
+
+
+
Fixed:
diff --git a/data/com.github.subhadeepjasu.pebbles.gschema.xml b/data/com.github.subhadeepjasu.pebbles.gschema.xml
index 0762b8af..7a8f5cda 100644
--- a/data/com.github.subhadeepjasu.pebbles.gschema.xml
+++ b/data/com.github.subhadeepjasu.pebbles.gschema.xml
@@ -28,7 +28,7 @@
-
+
-1
The saved x-position of the window.
diff --git a/meson.build b/meson.build
index 072c4ff4..e3763962 100644
--- a/meson.build
+++ b/meson.build
@@ -2,7 +2,7 @@
project (
'com.github.subhadeepjasu.pebbles',
'vala', 'c',
- version: '2.0.2',
+ version: '2.0.3',
)
# GNOME module
diff --git a/src/Core/Programmer.vala b/src/Core/Programmer.vala
deleted file mode 100644
index 7641c45f..00000000
--- a/src/Core/Programmer.vala
+++ /dev/null
@@ -1,324 +0,0 @@
-/*-
- * Copyright (c) 2017-2020 Subhadeep Jasu
- * Copyright (c) 2017-2020 Saunak Biswas
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- * Authored by: Subhadeep Jasu
- * Saunak Biswas
- */
-namespace Pebbles {
- public enum WordSize {
- BYTE=8,
- WORD=16,
- DWORD=32,
- QWORD=64
- }
- public errordomain CalcError {
- DIVIDE_BY_ZERO
- }
- public class Programmer {
- public WordSize word_size;
- public bool[] output;
- public bool carry;
- public bool aux_carry;
- public bool f0;
- public bool overflow_flag;
- public bool parity_flag;
- public bool zero_flag;
- public bool negative_flag;
-
- public Programmer() {
- output =new bool[64];
- }
- public bool xor_each_bit (bool a, bool b) {
- if(a == b) {
- return false;
- }
- return true;
- }
- public bool full_add (bool a, bool b) {
- bool c = carry;
- carry = (a && b) || (b && carry) || (a && carry);
- return xor_each_bit(c, xor_each_bit(a,b));
- }
- public bool[] add (bool[] input_a, bool[] input_b, int? word_size = 8) {
- for(int i=63; i>63-word_size;i--) {
- output[i] = full_add(input_a[i], input_b[i]); //always set carry to false on first iteration
- }
- return output;
- }
- public bool[] ones_complement(bool[] input, int? word_size = 8) {
- for(int i=64-word_size;i<64;i++) {
- output[i] = !input[i]; //always set carry to false on first iteration
- }
- return output;
- }
- public bool[] twos_complement(bool[] input, int? word_size = 8) {
- bool[] input_copy = ones_complement(input, word_size);
- bool[] binary_one = new bool[64];
- binary_one[63] = true;
- add(input_copy, binary_one, word_size);
- return output;
- }
- public bool[] subtract (bool[] input_a, bool[] input_b, int? word_size = 8) {
- bool[] input_b_copy = twos_complement(input_b, word_size);
- add(input_a, input_b_copy, word_size);
- return output;
- }
- public bool multiply_two_bits (bool a, bool b) {
- if(a == true && b == true) {
- return true;
- }
- return false;
- }
- public string multiply (bool[] input_a, bool[] input_b, int? word_size = 8) {
- // bool[] input_a_copy =new bool[64];
- // bool[] input_b_copy =new bool[64];
- // print(word_size.to_string());
- // for(int i=0; i<64-(int)word_size;i++) {
- // input_a_copy[i] = false;
- // input_b_copy[i] = false;
- // }
- // for(int i=64-(int)word_size; i<64;i++) {
- // input_a_copy[i] = input_a[i];
- // input_b_copy[i] = input_b[i];
- // }
- // bool[] bit_product;
- // bool[] sum_of_products = new bool[64];
- // int k=0;
- // for (int i=63;i>=64-(int)word_size;i--) {
- // bit_product = new bool[64];
- // //check if bit taken in multiplier is 1 then multiply and add to obtain final result else if 0 then skip
- // if(input_b_copy[i]==true) {
- // for (int j=63-k; j>=64-(int)word_size; j--) {
- // //each_bit_product[i,j] = multiply_two_bits(input_a_copy[j+k], input_b_copy[i]);
- // bit_product[j] = multiply_two_bits(input_a_copy[j+k], input_b_copy[i]);
-
- // }
- // carry = false;
- // sum_of_products = add(sum_of_products,bit_product);
- // }
- // k++;
- // }
- // output = sum_of_products;
- // return output;
- string input_a_s = "";
- string input_b_s = "";
- for (int i = 63; i >= 0; i--) {
- input_a_s = ((input_a[i]) ? "1" : "0") + input_a_s;
- input_b_s = ((input_b[i]) ? "1" : "0") + input_b_s;
- }
- int64 int_dividend;
- int64.from_string (input_a_s, out int_dividend, 2);
- int64 int_divisor;
- int64.from_string (input_b_s, out int_divisor, 2);
- //print("%s * %s", int_dividend.to_string (), int_divisor.to_string ());
- int64 product = int_dividend * int_divisor;
- return product.to_string ();
- }
-
- // Naive integer division using OS (Meant to be replaced by restoring division)
- public string division_signed_integer (bool[] input_a, bool[] input_b, int? word_size = 8) {
- string dividend = "";
- string divisor = "";
- for (int i = 63; i >= 0; i--) {
- dividend = ((input_a[i]) ? "1" : "0") + dividend;
- divisor = ((input_b[i]) ? "1" : "0") + divisor;
- }
- int64 int_dividend;
- int64.from_string (dividend, out int_dividend, 2);
- int64 int_divisor;
- int64.from_string (divisor, out int_divisor, 2);
- //print("%s / %s\n", int_dividend.to_string (), int_divisor.to_string ());
- if (int_divisor == 0) {
- return "Error";
- }
- int64 quotient = int_dividend / int_divisor;
- return quotient.to_string ();
- }
- // Again, naive
- public string mod_signed_integer (bool[] input_a, bool[] input_b, int? word_size = 8) {
- string dividend = "";
- string divisor = "";
- for (int i = 63; i >= 0; i--) {
- dividend = ((input_a[i]) ? "1" : "0") + dividend;
- divisor = ((input_b[i]) ? "1" : "0") + divisor;
- }
- int64 int_dividend;
- int64.from_string (dividend, out int_dividend, 2);
- int64 int_divisor;
- int64.from_string (divisor, out int_divisor, 2);
- //print("%s / %s\n", int_dividend.to_string (), int_divisor.to_string ());
- if (int_divisor == 0) {
- return "Error";
- }
- int64 remainder = int_dividend % int_divisor;
- return remainder.to_string ();
- }
-
- // Restoring division algorithm (needs to be fixed, may be the whole logic is incorrect here :v)
- public bool[] division_quotient (bool[] input_a, bool[] input_b, int? word_size = 8) {
- //print("Inputs for division:");
- //for(int j = 0; j< 64 ; j++){ print(input_a[j]?"1":"0"); }
- //print("\n");
- //for(int j = 0; j< 64 ; j++){ print(input_b[j]?"1":"0"); }
- //print("\n");
- bool[] dividend = new bool[64];
- for (int i = 63; i >= 64 - input_a.length; i--) {
- dividend[i] = input_a[i];
- }
- int comparator_result;
- //for left shifting dividend/remainder by 1
- bool[] shift_size = new bool[64];
- shift_size[63] = true;
- output = new bool[64];
- int right_most = find_right_most_one (input_a);
- //print("rightmost: %d", right_most);
- for(int i=64-(int)word_size +right_most; i<64; i++) {
- dividend = left_shift(dividend, shift_size, dividend[64 - word_size], word_size);
- //print("Left shift : ");
- //for(int j = 0; j< 64 ; j++){ print(dividend[j]?"1":"0"); }
- //print("\n");
- dividend[63] = input_a[i];
- comparator_result = comparator(dividend, input_b, word_size);
- //print("i : %d , Comparator : %d \n" , i, comparator_result);
- if(comparator_result == -1) {
- output[i] = false;
- }
- else {
- output[i] = true;
- // print("Subtract for div : ");
- // for(int j = 0; j< 64 ; j++){ print(dividend[j]?"1":"0"); }
- // print("\n");
- // for(int j = 0; j< 64 ; j++){ print(input_b[j]?"1":"0"); }
- // print("\n");
- dividend = subtract(dividend, input_b, word_size);
- // for(int j = 0; j< 64 ; j++){ print(dividend[j]?"1":"0"); }
- // print("\n");
- }
- }
- return output;
- }
-
- private int find_right_most_one (bool[] input) {
- int i = 0;
- for (; i < input.length; i++) {
- if (input[i] == true) {
- break;
- }
- }
- return (input.length - i);
- }
-
- /***
- compares two boolean arrays and returns an integer based on the following:
- ab return 1
- */
-
- public int comparator(bool[] input_a, bool[] input_b, int? word_size = 8) {
- for(int i=64-(int)word_size; i<64;i++) {
- if(input_a[i] == false && input_b[i] == true) {
- return -1;
- }
- else if(input_a[i] == input_b[i]) {
- continue;
- }
- else {
- return 1;
- }
- }
- return 0;
- }
-
- public bool[] left_shift(bool[] input_a, bool[] input_b, bool fill_bits, int? word_size = 8) {
- int64 shift_amount;
- string shift_amount_binary_string = "";
- for (int i = 63; i >= 0; i--) {
- shift_amount_binary_string = ((input_b[i]) ? "1" : "0") + shift_amount_binary_string;
- }
- int64.from_string (shift_amount_binary_string, out shift_amount, 2);
- if (shift_amount < 1)
- shift_amount = 1;
- if (shift_amount > word_size)
- shift_amount = word_size;
- for(int i=64-(int)word_size+(int)shift_amount; i<64;i++) {
- output[i-shift_amount] = input_a[i];
- }
- output[63] = fill_bits;
- return output;
- }
-
- public bool[] right_shift(bool[] input_a, bool[] input_b, bool fill_bits, int? word_size = 8) {
- int64 shift_amount;
- string shift_amount_binary_string = "";
- for (int i = 63; i >= 0; i--) {
- shift_amount_binary_string = ((input_b[i]) ? "1" : "0") + shift_amount_binary_string;
- }
- int64.from_string (shift_amount_binary_string, out shift_amount, 2);
- if (shift_amount < 1)
- shift_amount = 1;
- if (shift_amount > word_size)
- shift_amount = word_size;
- for (int i = 64-word_size; i < 64 - shift_amount; i++) {
- output[i+shift_amount] = input_a[i];
- }
- output[0] = fill_bits;
- return output;
- }
-
- public bool[] and(bool[] input_a, bool[] input_b, int? word_size = 8) {
- for(int i=64-(int)word_size; i<64;i++) {
- output[i] = input_a[i] && input_b[i];
- }
- return output;
- }
- public bool[] nand(bool[] input_a, bool[] input_b, int? word_size = 8) {
- for(int i=64-(int)word_size; i<64;i++) {
- output[i] = !(input_a[i] && input_b[i]);
- }
- return output;
- }
- public bool[] or(bool[] input_a, bool[] input_b, int? word_size = 8) {
- for(int i=64-(int)word_size; i<64;i++) {
- output[i] = input_a[i] || input_b[i];
- }
- return output;
- }
- public bool[] nor(bool[] input_a, bool[] input_b, int? word_size = 8) {
- for(int i=64-(int)word_size; i<64;i++) {
- output[i] = !(input_a[i] || input_b[i]);
- }
- return output;
- }
- public bool[] xor(bool[] input_a, bool[] input_b, int? word_size = 8) {
- for(int i=64-word_size; i<64;i++) {
- output[i] = xor_each_bit(input_a[i], input_b[i]);
- }
- return output;
- }
- public bool[] xnor(bool[] input_a, bool[] input_b, int? word_size = 8) {
- for(int i=64-(int)word_size; i<64;i++) {
- output[i] = !(xor_each_bit(input_a[i], input_b[i]));
- }
- return output;
- }
- public bool[] not(bool[] input, int? word_size = 8) {
- output = ones_complement(input, word_size);
- return output; //not() does not modify output buffer
- }
- }
-}
diff --git a/src/Core/ProgrammerCalculator.vala b/src/Core/ProgrammerCalculator.vala
index e522652e..af4277b4 100644
--- a/src/Core/ProgrammerCalculator.vala
+++ b/src/Core/ProgrammerCalculator.vala
@@ -12,13 +12,19 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
+ * You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authored by: Subhadeep Jasu
* Saunak Biswas
*/
namespace Pebbles {
+
+ public errordomain CalcError {
+ DIVIDE_BY_ZERO
+ }
+
+
public class ProgrammerCalculator {
private const char[] HEXADECIMAL_DIGITS = { 'a', 'b', 'c', 'd', 'e', 'f'};
public enum TokenType {
@@ -43,7 +49,7 @@ namespace Pebbles {
str += "\"type\": \"parenthesis\"";
break;
}
-
+
str += ",\n\t";
switch (number_system) {
case NumberSystem.BINARY:
@@ -60,7 +66,7 @@ namespace Pebbles {
break;
}
str += "\n}";
-
+
return str;
}
}
@@ -176,35 +182,61 @@ namespace Pebbles {
return "";
}
+ string decimal_to_binary_int_unsigned (uint64 k) {
+ string bin = "";
+ var n = k;
+ for (int i = 0; n > 0; i++) {
+ bin = ((uint8)(n%2)).to_string() + bin;
+ n = (uint64)(n/2);
+ }
+
+ return bin;
+ }
public string convert_decimal_to_binary (string number, GlobalWordLength? wrd_length = GlobalWordLength.WRD, bool? format = false) {
- int[] temp = new int[64];
- int64 decimal = int64.parse (number);
- int i = 0;
- for (; decimal > 0; i++) {
- temp[i] = (int)Math.fabs(decimal%2);
- decimal/=2;
+ uint64 decimal = uint64.parse (number);
+ print ("%s......\n", decimal.to_string());
+ if (number.contains("-")) {
+ switch (wrd_length) {
+ case GlobalWordLength.BYT:
+ decimal += 128;
+ break;
+ case GlobalWordLength.WRD:
+ decimal += 32768;
+ break;
+ case GlobalWordLength.DWD:
+ decimal += 2147483648;
+ break;
+ case GlobalWordLength.QWD:
+ decimal += 9223372036854775808;
+ break;
+ }
}
- string binary = "";
- for (i = i - 1; i >= 0; i--) {
- binary += temp[i].to_string ();
+ print ("%s......\n", decimal.to_string());
+ string binary = decimal_to_binary_int_unsigned(decimal).to_string();
+ print ("%s b\n", binary);
+ binary = represent_binary_by_word_length (binary, wrd_length, format);
+ if (number.contains("-")) {
+ binary = binary.substring(1, -1);
+ binary = "1" + binary;
}
- return represent_binary_by_word_length (binary, wrd_length, format);
- }
- public string convert_binary_to_decimal (string number, GlobalWordLength? wrd_length = GlobalWordLength.WRD, bool? negative = false) {
+ print ("%s n\n", binary);
+ return binary;
+ }
+ public string convert_binary_to_decimal (string number, GlobalWordLength? wrd_length = GlobalWordLength.WRD) {
string formatted_binary = represent_binary_by_word_length (number, wrd_length);
- int64 decimal = 0;
- string converted_binary = formatted_binary;
- if (negative) {
- converted_binary = "";
- for (int i = 0; i < formatted_binary.length; i++) {
- converted_binary += (formatted_binary.get(i) == '1') ? "0" : "1";
- }
- int64.from_string (converted_binary, out decimal, 2);
- return "-" + (decimal + 1).to_string ();
- }
- int64.from_string (converted_binary, out decimal, 2);
+ int64 decimal = ProgrammerCalculator.convert_signed_binary_to_decimal(formatted_binary);
return decimal.to_string ();
}
+ public static int64 convert_signed_binary_to_decimal (string binary) {
+ int64 dec = 0;
+ for (uint i = binary.length - 1; i > 0; i--){
+ dec += (binary.get(i) == '1') ? (int64) pow64 (2, (binary.length - 1) - i) : 0;
+ }
+ if (binary.get(0) == '1') {
+ return dec - (int64)pow64 (2, binary.length - 1);
+ }
+ return dec;
+ }
public string represent_binary_by_word_length (string binary_value, GlobalWordLength wrd_length = GlobalWordLength.BYT, bool? format = false) {
string new_binary = "";
switch (wrd_length) {
@@ -278,7 +310,7 @@ namespace Pebbles {
hexa += temp.to_string ();
} else {
hexa += HEXADECIMAL_DIGITS [temp - 10].to_string ();
- }
+ }
i++;
n /= 16;
}
@@ -296,76 +328,76 @@ namespace Pebbles {
return decimal.to_string ();
}
- public string convert_hexadecimal_to_binary(string hex_value, GlobalWordLength? wrd_length = GlobalWordLength.WRD, bool? format = false)
- {
- long i = 0;
+ public string convert_hexadecimal_to_binary(string hex_value, GlobalWordLength? wrd_length = GlobalWordLength.WRD, bool? format = false)
+ {
+ long i = 0;
string binary_value = "";
- while (i < hex_value.length) {
-
- switch (hex_value.get_char (i)) {
- case '0':
- binary_value += "0000";
- break;
- case '1':
- binary_value += "0001";
- break;
- case '2':
- binary_value += "0010";
- break;
- case '3':
- binary_value += "0011";
- break;
- case '4':
- binary_value += "0100";
- break;
- case '5':
- binary_value += "0101";
- break;
- case '6':
- binary_value += "0110";
- break;
- case '7':
- binary_value += "0111";
- break;
- case '8':
- binary_value += "1000";
- break;
- case '9':
- binary_value += "1001";
- break;
- case 'A':
- case 'a':
- binary_value += "1010";
- break;
- case 'B':
- case 'b':
- binary_value += "1011";
- break;
- case 'C':
- case 'c':
- binary_value += "1100";
- break;
- case 'D':
- case 'd':
- binary_value += "1101";
- break;
- case 'E':
- case 'e':
- binary_value += "1110";
- break;
- case 'F':
- case 'f':
- binary_value += "1111";
- break;
- default:
- break;
- }
- i++;
- }
-
+ while (i < hex_value.length) {
+
+ switch (hex_value.get_char (i)) {
+ case '0':
+ binary_value += "0000";
+ break;
+ case '1':
+ binary_value += "0001";
+ break;
+ case '2':
+ binary_value += "0010";
+ break;
+ case '3':
+ binary_value += "0011";
+ break;
+ case '4':
+ binary_value += "0100";
+ break;
+ case '5':
+ binary_value += "0101";
+ break;
+ case '6':
+ binary_value += "0110";
+ break;
+ case '7':
+ binary_value += "0111";
+ break;
+ case '8':
+ binary_value += "1000";
+ break;
+ case '9':
+ binary_value += "1001";
+ break;
+ case 'A':
+ case 'a':
+ binary_value += "1010";
+ break;
+ case 'B':
+ case 'b':
+ binary_value += "1011";
+ break;
+ case 'C':
+ case 'c':
+ binary_value += "1100";
+ break;
+ case 'D':
+ case 'd':
+ binary_value += "1101";
+ break;
+ case 'E':
+ case 'e':
+ binary_value += "1110";
+ break;
+ case 'F':
+ case 'f':
+ binary_value += "1111";
+ break;
+ default:
+ break;
+ }
+ i++;
+ }
+
string formatted_binary = represent_binary_by_word_length (binary_value, wrd_length, format);
return formatted_binary;
- }
+ }
public static string map_bin_to_hex (string bin) {
switch (bin) {
case "0000":
@@ -373,42 +405,43 @@ namespace Pebbles {
case "0001":
return "1";
case "0010":
- return "2";
+ return "2";
case "0011":
- return "3";
+ return "3";
case "0100":
- return "4";
+ return "4";
case "0101":
- return "5";
+ return "5";
case "0110":
- return "6";
+ return "6";
case "0111":
- return "7";
+ return "7";
case "1000":
- return "8";
+ return "8";
case "1001":
- return "9";
+ return "9";
case "1010":
- return "a";
+ return "a";
case "1011":
- return "b";
+ return "b";
case "1100":
- return "b";
+ return "b";
case "1101":
- return "d";
+ return "d";
case "1110":
- return "e";
+ return "e";
case "1111":
- return "f";
+ return "f";
}
return "";
}
- public string convert_binary_to_hexadecimal (string bin_value, GlobalWordLength? wrd_length = GlobalWordLength.BYT, bool? negative = false) {
+ public string convert_binary_to_hexadecimal (string bin_value, GlobalWordLength? wrd_length = GlobalWordLength.BYT) {
string bin = represent_binary_by_word_length (bin_value, wrd_length, false);
int i = 0;
string hex_value = "";
string converted_binary = bin;
+ bool negative = bin[0] == '1';
if (negative) {
converted_binary = "";
for (i = 0; i < bin.length; i++) {
@@ -417,19 +450,19 @@ namespace Pebbles {
}
i = 0;
while (true) {
- // one by one extract from left, substring
- // of size 4 and add its hex code
- hex_value += map_bin_to_hex(converted_binary.substring(i, 4));
- i += 4;
- if (i == converted_binary.length || converted_binary == "")
- break;
- // if '.' is encountered add it
- // to result
- if (converted_binary.get_char(i) == '.')
- {
- hex_value += ".";
- i++;
- }
+ // one by one extract from left, substring
+ // of size 4 and add its hex code
+ hex_value += map_bin_to_hex(converted_binary.substring(i, 4));
+ i += 4;
+ if (i == converted_binary.length || converted_binary == "")
+ break;
+ // if '.' is encountered add it
+ // to result
+ if (converted_binary.get_char(i) == '.')
+ {
+ hex_value += ".";
+ i++;
+ }
}
while (hex_value.has_prefix ("0")) {
hex_value = hex_value.splice (0, 1, "");
@@ -444,18 +477,23 @@ namespace Pebbles {
return (hex_value.chug () == "") ? "0" : hex_value;
}
- public string convert_binary_to_octal (string bin_value, GlobalWordLength? wrd_length = GlobalWordLength.BYT, bool? negative = false) {
+ public string convert_binary_to_octal (string bin_value, GlobalWordLength? wrd_length = GlobalWordLength.BYT) {
string binary_string = represent_binary_by_word_length (bin_value, wrd_length, false);
uint64 octalNum = 0, decimalNum = 0, count = 1;
string converted_binary = binary_string;
+ bool negative = binary_string[0] == '1';
if (negative) {
converted_binary = "";
for (int i = 0; i < binary_string.length; i++) {
converted_binary += (binary_string.get(i) == '1') ? "0" : "1";
}
}
- uint64.from_string (converted_binary, out decimalNum, 2);
+ try {
+ uint64.from_string (converted_binary, out decimalNum, 2);
+ } catch (Error e) {
+ decimalNum = ProgrammerCalculator.convert_signed_binary_to_decimal(binary_string);
+ }
if (negative) {
decimalNum++;
}
@@ -479,7 +517,7 @@ namespace Pebbles {
public string convert_octal_to_binary (string oct_value, GlobalWordLength? wrd_length = GlobalWordLength.BYT, bool? format = false) {
int64 octalNum = int64.parse (oct_value);
- int64 decimalNum = 0, binaryNum = 0, count = 0;
+ int64 decimalNum = 0, count = 0;
while(octalNum != 0) {
decimalNum += (int64)((octalNum%10) * pow64(8,count));
@@ -498,7 +536,7 @@ namespace Pebbles {
string bin_value = convert_octal_to_binary (oct_value, wrd_length);
return convert_binary_to_hexadecimal (bin_value, wrd_length);
}
- private uint64 pow64 (uint64 a, uint64 b) {
+ private static uint64 pow64 (uint64 a, uint64 b) {
uint64 c = 1;
for (uint64 i = 0; i < b; i++) {
c *= a;
@@ -538,79 +576,288 @@ namespace Pebbles {
}
}
- public bool[] apply_op (Programmer prog_calc, char op, bool[] a, bool[] b, int word_size) throws CalcError {
- bool[] bool_array = new bool[int.max(a.length, b.length)];
- switch (op) {
- case '+':
- return prog_calc.add (a, b, word_size);
- case '-':
- return prog_calc.subtract (b, a, word_size);
- case '*':
- string result = prog_calc.multiply (a, b, word_size);
- return string_to_bool_array (result, NumberSystem.DECIMAL, Settings.get_default().global_word_length);
- case '/':
- // This is using a hacky workaround for division which is not ideal.
- // There is a badly made restoring division function as well which
- // needs to be fixed and used.
- string result = prog_calc.division_signed_integer (b, a, word_size);
- if (result == "Error") {
- throw new CalcError.DIVIDE_BY_ZERO ("Dividing by zero not allowed");
- }
- return string_to_bool_array (result, NumberSystem.DECIMAL, Settings.get_default().global_word_length);
- case '&':
- return prog_calc.and (a, b, word_size);
- case '|':
- return prog_calc.or (a, b, word_size);
- case '!':
- return prog_calc.not (a, word_size);
- case '_':
- return prog_calc.nand (a, b, word_size);
- case 'o':
- return prog_calc.nor (a, b, word_size);
- case 'x':
- return prog_calc.xor (a, b, word_size);
- case 'n':
- return prog_calc.xnor (a, b, word_size);
- case 'm':
- // This is using a hacky workaround for division which is not ideal.
- // There is a badly made restoring division function as well which
- // needs to be fixed and used.
- string result = prog_calc.mod_signed_integer (b, a, word_size);
- if (result == "Error") {
- throw new CalcError.DIVIDE_BY_ZERO ("Dividing by zero not allowed");
- }
- return string_to_bool_array (result, NumberSystem.DECIMAL, Settings.get_default().global_word_length);
- case '<':
- return prog_calc.left_shift (b, a, false, word_size);
- case '>':
- return prog_calc.right_shift (b, a, false, word_size);
+ public bool[] apply_op (char op, bool[] a_input, bool[] b_input, Pebbles.GlobalWordLength word_size) throws CalcError {
+ bool[] ret_val = new bool[64];
+ if (word_size == GlobalWordLength.BYT) {
+ int8 a = 0;
+ int8 b = 0;
+ int8 result = 0;
+
+ string str_a = "";
+ string str_b = "";
+ for (int i = 56; i < 64; i++) {
+ str_a += a_input[i] ? "1" : "0";
+ str_b += b_input[i] ? "1" : "0";
+ }
+ a = (int8)ProgrammerCalculator.convert_signed_binary_to_decimal(str_a);
+ b = (int8)ProgrammerCalculator.convert_signed_binary_to_decimal(str_b);
+ print ("%d %c %d = ", b, op, a);
+ switch (op) {
+ case '+':
+ result = a + b;
+ break;
+ case '-':
+ result = b - a;
+ break;
+ case '*':
+ result = a * b;
+ break;
+ case '/':
+ if (a == 0) {
+ throw new CalcError.DIVIDE_BY_ZERO ("Dividing by zero not allowed");
+ } else {
+ result = b / a;
+ }
+ break;
+ case '&':
+ result = a & b;
+ break;
+ case '|':
+ result = a | b;
+ break;
+ case '!':
+ result = ~a;
+ break;
+ case '_':
+ result = ~(a & b);
+ break;
+ case 'o':
+ result = ~(a | b);
+ break;
+ case 'x':
+ result = (a | b) & (~a | ~b);
+ break;
+ case 'n':
+ result = (a & b) | (~a & ~b);
+ break;
+ case 'm':
+ if (a == 0) {
+ throw new CalcError.DIVIDE_BY_ZERO ("Dividing by zero not allowed");
+ } else {
+ result = b % a;
+ }
+ break;
+ case '<':
+ result = b << a;
+ break;
+ case '>':
+ result = b >> a;
+ break;
+ }
+ print ("%d\n", result);
+ return string_to_bool_array(result.to_string(), Pebbles.NumberSystem.DECIMAL, Pebbles.GlobalWordLength.BYT);
+ } else if (word_size == GlobalWordLength.WRD) {
+ int16 a = 0;
+ int16 b = 0;
+ int16 result = 0;
+
+ string str_a = "";
+ string str_b = "";
+ for (int i = 48; i < 64; i++) {
+ str_a += a_input[i] ? "1" : "0";
+ str_b += b_input[i] ? "1" : "0";
+ }
+ a = (int16)ProgrammerCalculator.convert_signed_binary_to_decimal(str_a);
+ b = (int16)ProgrammerCalculator.convert_signed_binary_to_decimal(str_b);
+ print ("%d %c %d = ", b, op, a);
+ switch (op) {
+ case '+':
+ result = a + b;
+ break;
+ case '-':
+ result = b - a;
+ break;
+ case '*':
+ result = a * b;
+ break;
+ case '/':
+ if (a == 0) {
+ throw new CalcError.DIVIDE_BY_ZERO ("Dividing by zero not allowed");
+ } else {
+ result = b / a;
+ }
+ break;
+ case '&':
+ result = a & b;
+ break;
+ case '|':
+ result = a | b;
+ break;
+ case '!':
+ result = ~a;
+ break;
+ case '_':
+ result = ~(a & b);
+ break;
+ case 'o':
+ result = ~(a | b);
+ break;
+ case 'x':
+ result = (a | b) & (~a | ~b);
+ break;
+ case 'n':
+ result = (a & b) | (~a & ~b);
+ break;
+ case 'm':
+ if (a == 0) {
+ throw new CalcError.DIVIDE_BY_ZERO ("Dividing by zero not allowed");
+ } else {
+ result = b % a;
+ }
+ break;
+ case '<':
+ result = b << a;
+ break;
+ case '>':
+ result = b >> a;
+ break;
+ }
+ print ("%d\n", result);
+ return string_to_bool_array(result.to_string(), Pebbles.NumberSystem.DECIMAL, Pebbles.GlobalWordLength.WRD);
+ }if (word_size == GlobalWordLength.DWD) {
+ int32 a = 0;
+ int32 b = 0;
+ int32 result = 0;
+
+ string str_a = "";
+ string str_b = "";
+ for (int i = 32; i < 64; i++) {
+ str_a += a_input[i] ? "1" : "0";
+ str_b += b_input[i] ? "1" : "0";
+ }
+ a = (int8)ProgrammerCalculator.convert_signed_binary_to_decimal(str_a);
+ b = (int8)ProgrammerCalculator.convert_signed_binary_to_decimal(str_b);
+ print ("%d %c %d = ", b, op, a);
+ switch (op) {
+ case '+':
+ result = a + b;
+ break;
+ case '-':
+ result = b - a;
+ break;
+ case '*':
+ result = a * b;
+ break;
+ case '/':
+ if (a == 0) {
+ throw new CalcError.DIVIDE_BY_ZERO ("Dividing by zero not allowed");
+ } else {
+ result = b / a;
+ }
+ break;
+ case '&':
+ result = a & b;
+ break;
+ case '|':
+ result = a | b;
+ break;
+ case '!':
+ result = ~a;
+ break;
+ case '_':
+ result = ~(a & b);
+ break;
+ case 'o':
+ result = ~(a | b);
+ break;
+ case 'x':
+ result = (a | b) & (~a | ~b);
+ break;
+ case 'n':
+ result = (a & b) | (~a & ~b);
+ break;
+ case 'm':
+ if (a == 0) {
+ throw new CalcError.DIVIDE_BY_ZERO ("Dividing by zero not allowed");
+ } else {
+ result = b % a;
+ }
+ break;
+ case '<':
+ result = b << a;
+ break;
+ case '>':
+ result = b >> a;
+ break;
+ }
+ print ("%d\n", result);
+ return string_to_bool_array(result.to_string(), Pebbles.NumberSystem.DECIMAL, Pebbles.GlobalWordLength.DWD);
+ }if (word_size == GlobalWordLength.QWD) {
+ int64 a = 0;
+ int64 b = 0;
+ int64 result = 0;
+
+ string str_a = "";
+ string str_b = "";
+ for (int i = 0; i < 64; i++) {
+ str_a += a_input[i] ? "1" : "0";
+ str_b += b_input[i] ? "1" : "0";
+ }
+ a = ProgrammerCalculator.convert_signed_binary_to_decimal(str_a);
+ b = ProgrammerCalculator.convert_signed_binary_to_decimal(str_b);
+ print ("%l %c %l = ", b, op, a);
+ switch (op) {
+ case '+':
+ result = a + b;
+ break;
+ case '-':
+ result = b - a;
+ break;
+ case '*':
+ result = a * b;
+ break;
+ case '/':
+ if (a == 0) {
+ throw new CalcError.DIVIDE_BY_ZERO ("Dividing by zero not allowed");
+ } else {
+ result = b / a;
+ }
+ break;
+ case '&':
+ result = a & b;
+ break;
+ case '|':
+ result = a | b;
+ break;
+ case '!':
+ result = ~a;
+ break;
+ case '_':
+ result = ~(a & b);
+ break;
+ case 'o':
+ result = ~(a | b);
+ break;
+ case 'x':
+ result = (a | b) & (~a | ~b);
+ break;
+ case 'n':
+ result = (a & b) | (~a & ~b);
+ break;
+ case 'm':
+ if (a == 0) {
+ throw new CalcError.DIVIDE_BY_ZERO ("Dividing by zero not allowed");
+ } else {
+ result = b % a;
+ }
+ break;
+ case '<':
+ result = b << a;
+ break;
+ case '>':
+ result = b >> a;
+ break;
+ }
+ print ("%l\n", result);
+ return string_to_bool_array(result.to_string(), Pebbles.NumberSystem.DECIMAL, Pebbles.GlobalWordLength.QWD);
}
- return bool_array;
+
+ return ret_val;
}
- public string evaluate_exp (GlobalWordLength? wrd_length = GlobalWordLength.BYT, NumberSystem number_system, out bool[]? output_array = null) throws CalcError {
+ public string evaluate_exp (GlobalWordLength? wrd_length = GlobalWordLength.BYT, NumberSystem? number_system = NumberSystem.BINARY, out bool[]? output_array = null) throws CalcError {
CharStack ops = new CharStack (50);
BoolArrayStack values = new BoolArrayStack(50);
- Programmer prog_calc = new Programmer();
- int word_size = 8;
- prog_calc.word_size = WordSize.BYTE;
- switch (wrd_length) {
- case GlobalWordLength.BYT:
- prog_calc.word_size = WordSize.BYTE;
- break;
- case GlobalWordLength.WRD:
- prog_calc.word_size = WordSize.WORD;
- word_size = 16;
- break;
- case GlobalWordLength.DWD:
- prog_calc.word_size = WordSize.DWORD;
- word_size = 32;
- break;
- case GlobalWordLength.QWD:
- prog_calc.word_size = WordSize.QWORD;
- word_size = 64;
- break;
- }
for (int i = 0; i < stored_tokens.length; i++) {
if (stored_tokens[i].type == TokenType.OPERAND) {
//ops.push((char)(stored_tokens[i].token.get_char(0)));
@@ -622,7 +869,7 @@ namespace Pebbles {
else {
while (ops.peek() != '(') {
try {
- bool[] tmp = apply_op(prog_calc, ops.pop(), values.pop(), values.pop(), word_size);
+ bool[] tmp = apply_op(ops.pop(), values.pop(), values.pop(), wrd_length);
values.push(tmp);
} catch (CalcError e) {
throw e;
@@ -633,7 +880,7 @@ namespace Pebbles {
} else if (stored_tokens[i].type == TokenType.OPERATOR) {
while (!ops.empty() && has_precedence_pemdas(stored_tokens[i].token.get(0), ops.peek())) {
try {
- bool[] tmp = apply_op(prog_calc, ops.pop(), values.pop(), values.pop(), word_size);
+ bool[] tmp = apply_op(ops.pop(), values.pop(), values.pop(), wrd_length);
values.push(tmp);
} catch (CalcError e) {
throw e;
@@ -645,7 +892,7 @@ namespace Pebbles {
}
while (!ops.empty()) {
try {
- bool[] tmp = apply_op(prog_calc, ops.pop(), values.pop(), values.pop(), word_size);
+ bool[] tmp = apply_op(ops.pop(), values.pop(), values.pop(), wrd_length);
values.push(tmp);
} catch (CalcError e) {
throw e;
@@ -656,12 +903,13 @@ namespace Pebbles {
// Send the original array back for storage.
output_array = answer;
string output = bool_array_to_string (answer, wrd_length, number_system);
-
+
return output;
}
public bool[] string_to_bool_array (string str, NumberSystem number_system, GlobalWordLength wrd_length) {
bool[] bool_array = new bool[64];
string converted_str = "";
+ print ("%s: str\n", str);
switch (number_system) {
case NumberSystem.OCTAL:
converted_str = convert_octal_to_binary (str, wrd_length, true).replace (" ", "");
@@ -699,13 +947,13 @@ namespace Pebbles {
}
switch (number_system) {
case NumberSystem.OCTAL:
- str = convert_binary_to_octal (str, wrd_length, arr[0]);
+ str = convert_binary_to_octal (str, wrd_length);
break;
case NumberSystem.DECIMAL:
- str = convert_binary_to_decimal (str, wrd_length, arr[0]);
+ str = convert_binary_to_decimal (str, wrd_length);
break;
case NumberSystem.HEXADECIMAL:
- str = convert_binary_to_hexadecimal (str, wrd_length, arr[0]);
+ str = convert_binary_to_hexadecimal (str, wrd_length);
break;
default:
str = represent_binary_by_word_length (str, wrd_length);
diff --git a/src/Test/TestUtil.vala b/src/Test/TestUtil.vala
index 9a95d247..8691dd45 100644
--- a/src/Test/TestUtil.vala
+++ b/src/Test/TestUtil.vala
@@ -12,7 +12,7 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
+ * You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authored by: Subhadeep Jasu
@@ -22,9 +22,9 @@
namespace Pebbles {
public class TestUtil {
public static void show_greeter () {
- stdout.printf ("
- _____ _ _ _
-| _ |___| |_| |_| |___ ___
+ stdout.printf ("
+ _____ _ _ _
+| _ |___| |_| |_| |___ ___
| __| -_| . | . | | -_|_ -|
|__| |___|___|___|_|___|___|
\n");
@@ -50,146 +50,146 @@ namespace Pebbles {
private static void test_programmer_integration () {
var settings = Settings.get_default ();
settings.number_system = NumberSystem.DECIMAL;
- ProgrammerCalculator prog_calc_front = new ProgrammerCalculator ();
+ // ProgrammerCalculator prog_calc_front = new ProgrammerCalculator ();
}
- private static void test_programmer(string input1, string input2) {
- Programmer prog_calc = new Programmer();
- string[] input1_arr = input1.split(" ");
- string[] input2_arr = input2.split(" ");
- bool[] input_a = new bool[64];
- bool[] input_b = new bool[64];
- bool[] output;
- for (int i = 0; i< 64; i++) {
- if(input1_arr[i] == "0") {
- input_a[i] = false;
- }
- else {
- input_a[i] = true;
- }
-
- if(input2_arr[i] == "0") {
- input_b[i] = false;
- }
- else {
- input_b[i] = true;
- }
- }
+ // private static void test_programmer(string input1, string input2) {
+ // Programmer prog_calc = new Programmer();
+ // string[] input1_arr = input1.split(" ");
+ // string[] input2_arr = input2.split(" ");
+ // bool[] input_a = new bool[64];
+ // bool[] input_b = new bool[64];
+ // bool[] output;
+ // for (int i = 0; i< 64; i++) {
+ // if(input1_arr[i] == "0") {
+ // input_a[i] = false;
+ // }
+ // else {
+ // input_a[i] = true;
+ // }
- prog_calc.word_size = WordSize.BYTE;
- print("Binary 1's complement operation:");
- prog_calc.ones_complement(input_a);
- output = prog_calc.output;
- for(int i =0; i<64; i++) {
- print("%s",output[i]?"1":"0");
- }
- print("\n");
-
- prog_calc.word_size = WordSize.BYTE;
- print("Binary 2's complement operation:");
- prog_calc.twos_complement(input_a);
- output = prog_calc.output;
- for(int i =0; i<64; i++) {
- print("%s",output[i]?"1":"0");
- }
- print("\n");
+ // if(input2_arr[i] == "0") {
+ // input_b[i] = false;
+ // }
+ // else {
+ // input_b[i] = true;
+ // }
+ // }
- prog_calc.word_size = WordSize.BYTE;
- print("Binary Addition operation:");
- prog_calc.add(input_a, input_b);
- output = prog_calc.output;
- for(int i =0; i<64; i++) {
- print("%s",output[i]?"1":"0");
- }
- print("\n");
-
- print("Binary Subtraction operation:");
- prog_calc.subtract(input_a, input_b, 8);
- output = prog_calc.output;
- print("sub\n");
- for(int i =0; i<64; i++) {
- print("%s",output[i]?"1":"0");
- }
- print("\n");
+ // prog_calc.word_size = WordSize.BYTE;
+ // print("Binary 1's complement operation:");
+ // prog_calc.ones_complement(input_a);
+ // output = prog_calc.output;
+ // for(int i =0; i<64; i++) {
+ // print("%s",output[i]?"1":"0");
+ // }
+ // print("\n");
- print("Binary Multiplication operation:");
- prog_calc.multiply(input_a, input_b);
- output = prog_calc.output;
- for(int i =0; i<64; i++) {
- print("%s",output[i]?"1":"0");
- }
- print("\n");
+ // prog_calc.word_size = WordSize.BYTE;
+ // print("Binary 2's complement operation:");
+ // prog_calc.twos_complement(input_a);
+ // output = prog_calc.output;
+ // for(int i =0; i<64; i++) {
+ // print("%s",output[i]?"1":"0");
+ // }
+ // print("\n");
- print("Binary Division quotient operation:");
- prog_calc.division_quotient(input_a, input_b, 8);
- output = prog_calc.output;
- for(int i =0; i<64; i++) {
- print("%s",output[i]?"1":"0");
- }
- print("\n");
+ // prog_calc.word_size = WordSize.BYTE;
+ // print("Binary Addition operation:");
+ // prog_calc.add(input_a, input_b);
+ // output = prog_calc.output;
+ // for(int i =0; i<64; i++) {
+ // print("%s",output[i]?"1":"0");
+ // }
+ // print("\n");
- prog_calc.word_size = WordSize.BYTE;
- print("Binary And operation:");
- prog_calc.and(input_a, input_b);
- output = prog_calc.output;
- for(int i =0; i<64; i++) {
- print("%s",output[i]?"1":"0");
- }
- print("\n");
+ // print("Binary Subtraction operation:");
+ // prog_calc.subtract(input_a, input_b, 8);
+ // output = prog_calc.output;
+ // print("sub\n");
+ // for(int i =0; i<64; i++) {
+ // print("%s",output[i]?"1":"0");
+ // }
+ // print("\n");
- prog_calc.word_size = WordSize.BYTE;
- print("Binary Nand operation:");
- prog_calc.nand(input_a, input_b);
- output = prog_calc.output;
- for(int i =0; i<64; i++) {
- print("%s",output[i]?"1":"0");
- }
- print("\n");
+ // print("Binary Multiplication operation:");
+ // prog_calc.multiply(input_a, input_b);
+ // output = prog_calc.output;
+ // for(int i =0; i<64; i++) {
+ // print("%s",output[i]?"1":"0");
+ // }
+ // print("\n");
- prog_calc.word_size = WordSize.BYTE;
- print("Binary Or operation:");
- prog_calc.or(input_a, input_b);
- output = prog_calc.output;
- for(int i =0; i<64; i++) {
- print("%s",output[i]?"1":"0");
- }
- print("\n");
+ // print("Binary Division quotient operation:");
+ // prog_calc.division_quotient(input_a, input_b, 8);
+ // output = prog_calc.output;
+ // for(int i =0; i<64; i++) {
+ // print("%s",output[i]?"1":"0");
+ // }
+ // print("\n");
- prog_calc.word_size = WordSize.BYTE;
- print("Binary Nor operation:");
- prog_calc.nor(input_a, input_b);
- output = prog_calc.output;
- for(int i =0; i<64; i++) {
- print("%s",output[i]?"1":"0");
- }
- print("\n");
+ // prog_calc.word_size = WordSize.BYTE;
+ // print("Binary And operation:");
+ // prog_calc.and(input_a, input_b);
+ // output = prog_calc.output;
+ // for(int i =0; i<64; i++) {
+ // print("%s",output[i]?"1":"0");
+ // }
+ // print("\n");
- prog_calc.word_size = WordSize.BYTE;
- print("Binary Xor operation:");
- prog_calc.xor(input_a, input_b);
- output = prog_calc.output;
- for(int i =0; i<64; i++) {
- print("%s",output[i]?"1":"0");
- }
- print("\n");
+ // prog_calc.word_size = WordSize.BYTE;
+ // print("Binary Nand operation:");
+ // prog_calc.nand(input_a, input_b);
+ // output = prog_calc.output;
+ // for(int i =0; i<64; i++) {
+ // print("%s",output[i]?"1":"0");
+ // }
+ // print("\n");
- prog_calc.word_size = WordSize.BYTE;
- print("Binary Xnor operation:");
- prog_calc.xnor(input_a, input_b);
- output = prog_calc.output;
- for(int i =0; i<64; i++) {
- print("%s",output[i]?"1":"0");
- }
- print("\n");
+ // prog_calc.word_size = WordSize.BYTE;
+ // print("Binary Or operation:");
+ // prog_calc.or(input_a, input_b);
+ // output = prog_calc.output;
+ // for(int i =0; i<64; i++) {
+ // print("%s",output[i]?"1":"0");
+ // }
+ // print("\n");
- prog_calc.word_size = WordSize.BYTE;
- print("Binary Not operation:");
- prog_calc.not(input_a);
- output = prog_calc.output;
- for(int i =0; i<64; i++) {
- print("%s",output[i]?"1":"0");
- }
- print("\n");
- }
+ // prog_calc.word_size = WordSize.BYTE;
+ // print("Binary Nor operation:");
+ // prog_calc.nor(input_a, input_b);
+ // output = prog_calc.output;
+ // for(int i =0; i<64; i++) {
+ // print("%s",output[i]?"1":"0");
+ // }
+ // print("\n");
+
+ // prog_calc.word_size = WordSize.BYTE;
+ // print("Binary Xor operation:");
+ // prog_calc.xor(input_a, input_b);
+ // output = prog_calc.output;
+ // for(int i =0; i<64; i++) {
+ // print("%s",output[i]?"1":"0");
+ // }
+ // print("\n");
+
+ // prog_calc.word_size = WordSize.BYTE;
+ // print("Binary Xnor operation:");
+ // prog_calc.xnor(input_a, input_b);
+ // output = prog_calc.output;
+ // for(int i =0; i<64; i++) {
+ // print("%s",output[i]?"1":"0");
+ // }
+ // print("\n");
+
+ // prog_calc.word_size = WordSize.BYTE;
+ // print("Binary Not operation:");
+ // prog_calc.not(input_a);
+ // output = prog_calc.output;
+ // for(int i =0; i<64; i++) {
+ // print("%s",output[i]?"1":"0");
+ // }
+ // print("\n");
+ // }
private static void test_date_difference (int d1, int m1, int y1, int d2, int m2, int y2, string days, string year, string month, string week, string day) {
DateTime start_date_time = new DateTime( new TimeZone.local() , y1 , m1 , d1 , 0 , 0 , 0 );
DateTime end_date_time = new DateTime( new TimeZone.local() , y2 , m2 , d2 , 0 , 0 , 0 );
@@ -213,7 +213,7 @@ namespace Pebbles {
stdout.printf ("\nTesting Tokenization...\n");
stdout.printf ("-------------------------------------------------------------\n");
- /*
+ /*
* Certain UTF-8 escape characters require a space
* after it to seperate it from the next character.
* This is only during testing. This is however not
@@ -229,10 +229,10 @@ namespace Pebbles {
stdout.printf ("\nTesting Bracket Balance Check...\n");
stdout.printf ("-------------------------------------------------------------");
test_tokenize ("2 + (9 - 5)\xC3\x97 5 - (8-7))");
-
+
stdout.printf ("\nTesting Scientific Calculator\n");
stdout.printf ("-------------------------------------------------------------\n");
-
+
test_scientific ("2+2", "4");
test_scientific ("4.23+ 1.11", "5.34");
test_scientific (".13+.51", "0.64");
@@ -283,7 +283,7 @@ namespace Pebbles {
test_scientific ("10 + 5 - 10%", "14.9");
test_scientific ("100 + 20%", "120");
test_scientific ("20% + 100", "100.2");
-
+
stdout.printf ("\nIntegration Testing Programmer Calculator\n");
stdout.printf ("-------------------------------------------------------------\n");
@@ -291,18 +291,18 @@ namespace Pebbles {
stdout.printf ("\nTesting Programmer New Calculator\n");
stdout.printf ("-------------------------------------------------------------\n");
-
- test_programmer("0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0", "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1");
- test_programmer("0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0", "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1");
- test_programmer("0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0", "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0 1 0 1 1");
- test_programmer("0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1", "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1");
-
+
+ // test_programmer("0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0", "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1");
+ // test_programmer("0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0", "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1");
+ // test_programmer("0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0", "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0 1 0 1 1");
+ // test_programmer("0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1", "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1");
+
stdout.printf ("\nTesting Date Difference Calculator\n");
stdout.printf ("-------------------------------------------------------------\n");
-
+
test_date_difference (20, 11, 2018, 30, 11, 2018, "10", "0", "0", "1", "3");
test_date_difference (17, 1, 2019, 7, 2, 2042, "8422", "23", "0", "3", "0");
- test_date_difference (20, 11, 2018, 20, 11, 2018, "0", "0", "0", "0", "0");
+ test_date_difference (20, 11, 2018, 20, 11, 2018, "0", "0", "0", "0", "0");
}
}
}
diff --git a/src/meson.build b/src/meson.build
index 3124977f..404da512 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -17,7 +17,6 @@ sources = files (
'Core/ScientificCalculator.vala',
'Core/Calculus.vala',
'Core/ProgrammerCalculator.vala',
- 'Core/Programmer.vala',
'Core/Statistics.vala',
'Core/Utils.vala',
'Core/Converter.vala',