Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added decimal arithmatic devices and fixed crash bug if unknown device

  • Loading branch information...
commit 1f920f396816da8a2454d3f2a19ebba2f06cc455 1 parent 7c4fee9
@EnKrypt authored
View
BIN  CUI-EBot/EBot.class
Binary file not shown
View
BIN  CUI-EBot/EBot.jar
Binary file not shown
View
18 CUI-EBot/EBot.java
@@ -540,23 +540,23 @@ public String eval(String arg[]){
// System.out.println(i+" : "+arg[i]);
// }
if (arg[0].equalsIgnoreCase("add")){
- int cres=0;
+ double cres=0;
for (int i=1;i<arg.length;i++){
- cres+=Integer.parseInt(arg[i]);
+ cres+=Double.parseDouble(arg[i]);
}
return ""+cres;
}
else if (arg[0].equalsIgnoreCase("sub")){
- int cres=Integer.parseInt(arg[1]);
+ double cres=Double.parseDouble(arg[1]);
for (int i=2;i<arg.length;i++){
- cres-=Integer.parseInt(arg[i]);
+ cres-=Double.parseDouble(arg[i]);
}
return ""+cres;
}
else if (arg[0].equalsIgnoreCase("mul")){
- int cres=Integer.parseInt(arg[1]);;
+ double cres=Double.parseDouble(arg[1]);;
for (int i=2;i<arg.length;i++){
- cres*=Integer.parseInt(arg[i]);
+ cres*=Double.parseDouble(arg[i]);
}
return ""+cres;
}
@@ -756,7 +756,7 @@ else if (arg[0].equalsIgnoreCase("runlambda")){
return "(eval '"+to_eval+"\")";
}
else{
- String devi="";
+ String devi="";
String param="";
for (int i=1;i<arg.length;i++){
param+=" "+arg[i];
@@ -764,8 +764,8 @@ else if (arg[0].equalsIgnoreCase("runlambda")){
try{
devi=mkdev.get(arg[0]).toString();
}
- catch(NullPointerException npe){
- devi="";
+ catch(Exception npe){
+ return "";
}
return "("+devi+param+")";
}
View
BIN  EBot.class
Binary file not shown
View
BIN  EBot.jar
Binary file not shown
View
16 EBot.java
@@ -559,23 +559,23 @@ public String eval(String arg[]){
// System.out.println(i+" : "+arg[i]);
// }
if (arg[0].equalsIgnoreCase("add")){
- int cres=0;
+ double cres=0;
for (int i=1;i<arg.length;i++){
- cres+=Integer.parseInt(arg[i]);
+ cres+=Double.parseDouble(arg[i]);
}
return ""+cres;
}
else if (arg[0].equalsIgnoreCase("sub")){
- int cres=Integer.parseInt(arg[1]);
+ double cres=Double.parseDouble(arg[1]);
for (int i=2;i<arg.length;i++){
- cres-=Integer.parseInt(arg[i]);
+ cres-=Double.parseDouble(arg[i]);
}
return ""+cres;
}
else if (arg[0].equalsIgnoreCase("mul")){
- int cres=Integer.parseInt(arg[1]);;
+ double cres=Double.parseDouble(arg[1]);;
for (int i=2;i<arg.length;i++){
- cres*=Integer.parseInt(arg[i]);
+ cres*=Double.parseDouble(arg[i]);
}
return ""+cres;
}
@@ -783,8 +783,8 @@ else if (arg[0].equalsIgnoreCase("runlambda")){
try{
devi=mkdev.get(arg[0]).toString();
}
- catch(NullPointerException npe){
- devi="";
+ catch(Exception npe){
+ return "";
}
return "("+devi+param+")";
}
Please sign in to comment.
Something went wrong with that request. Please try again.