Post Reply 
ENG button in Casio calculator
10-30-2015, 05:09 PM (This post was last modified: 06-09-2016 06:16 AM by cclinus.)
Post: #1
ENG button in Casio calculator
Hi,

I like the ENG button in Casio calculator. It display number in engineering format and convert exponent(For example xxxE3 to xxxE6, xxxE6 to xxxE9 or reverse).
HP prime seems do not have this button. So I make one for my HP prime.
You may find that I use a dumb method to do the conversion. If you have better method, it is welcome to post it in this thread.

Operation:
1)Key press: [Shift > User > * (Multiplication)] : exponent+3, E-12>E-9....E3>E6>E9>E12
2)Key press: [Shift > User > / (Division)] : exponent-3, E12>E9....E-3>E-6>E-9>E-12
3)Key press: [Shift > User > + (Addition)] : convert string back to number

Screen shot:
   

ENG program:
Code:

EXPORT ENGA(x)
BEGIN
LOCAL pos,s,i,sign;

IF TYPE(x)==0 THEN
s:=STRING(x,4,11);
WHILE INSTRING(s,"0ᴇ") DO
s:=REPLACE(s,"0ᴇ","ᴇ")
END;
RETURN s;
END;
IF (TYPE(x)==2) AND (INSTRING(x,"ᴇ12")) THEN
RETURN x;
END;
IF (TYPE(x)==2) AND (INSTRING(x,"ᴇ12")==0) THEN
IF CHAR(x(1))=="−" THEN
   sign:="−";
   x:=RIGHT(x,DIM(x)-1);
ELSE
   sign:="";
END;
s:=x;
FOR i FROM 1 TO 3 DO
pos:=INSTRING(s,".");
s(pos):=s(pos-1);
s(pos-1):=".";
IF pos==2 THEN
s:="0"+s;
END;
END;
WHILE INSTRING(s,"0ᴇ") DO
s:=REPLACE(s,"0ᴇ","ᴇ")
END;
//
s:=REPLACE(s,"ᴇ9","ᴇ12");
s:=REPLACE(s,"ᴇ6","ᴇ9");
s:=REPLACE(s,"ᴇ3","ᴇ6");
s:=REPLACE(s,"ᴇ0","ᴇ3");
s:=REPLACE(s,"ᴇ−3","ᴇ0");
s:=REPLACE(s,"ᴇ−6","ᴇ−3");
s:=REPLACE(s,"ᴇ−9","ᴇ−6");
s:=REPLACE(s,"ᴇ−12","ᴇ−9");

s:=sign+s;
RETURN s;
END;
END;

EXPORT ENGB(x)
BEGIN
LOCAL pos,s,i,sign;
IF TYPE(x)==0 THEN
s:=STRING(x,4,11);
WHILE INSTRING(s,"0ᴇ") DO
s:=REPLACE(s,"0ᴇ","ᴇ")
END;
RETURN s;
END;
IF TYPE(x)==2 AND (INSTRING(x,"ᴇ−12"))THEN
RETURN x;
END;
IF TYPE(x)==2 AND (INSTRING(x,"ᴇ−12")==0)THEN
IF CHAR(x(1))=="−" THEN
   sign:="−";
   x:=RIGHT(x,DIM(x)-1);
ELSE
   sign:="";
END;
s:=x;
FOR i FROM 1 TO 3 DO
pos:=INSTRING(s,".");
IF s(pos+1)==7431 THEN
s:=REPLACE(s,".ᴇ","0.ᴇ");
ELSE
s(pos):=s(pos+1);
s(pos+1):=".";
IF (pos==2) AND (s(1)==48) THEN
s:=RIGHT(s,DIM(s)-1);
END;
END;
END;
WHILE INSTRING(s,"0ᴇ") DO
s:=REPLACE(s,"0ᴇ","ᴇ")
END;
//
s:=REPLACE(s,"ᴇ−9","ᴇ−12");
s:=REPLACE(s,"ᴇ−6","ᴇ−9");
s:=REPLACE(s,"ᴇ−3","ᴇ−6");
s:=REPLACE(s,"ᴇ0","ᴇ−3");
s:=REPLACE(s,"ᴇ3","ᴇ0");
s:=REPLACE(s,"ᴇ6","ᴇ3");
s:=REPLACE(s,"ᴇ9","ᴇ6");
s:=REPLACE(s,"ᴇ12","ᴇ9");
s:=sign+s;
RETURN s;
END;
END;

User Defined key:
Code:

KEY K_Mul()
BEGIN
RETURN "ENGA(Ans)";
END;

KEY K_Div()
BEGIN
RETURN "ENGB(Ans)";
END;

KEY K_Plus()
BEGIN
RETURN "EXPR(Ans)";
END;


.hpprgm  USERKEY.hpprgm (Size: 336 bytes / Downloads: 108)

.hpprgm  ENG.hpprgm (Size: 4.36 KB / Downloads: 83)

Last:
Feature request for HP prime:
1) Need "press Enter" function in program. So that I don't need to press Enter after pressing user defined key.
2) Reverse HELP/USER key. So that [Shift] for HELP, normal for USER. This could reduce key stroke for user defined key. Please add this option in Setting mode.

Thanks!

EDITED:2016-JUN-9
Correct negative number bug.
Delete the leading zeor. eg. 1.25000E0 => 1.25E0
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
ENG button in Casio calculator - cclinus - 10-30-2015 05:09 PM
RE: ENG button in Casio calculator - epp - 10-30-2015, 07:46 PM
RE: ENG button in Casio calculator - ww63 - 10-12-2017, 02:35 PM
RE: ENG button in Casio calculator - Tyann - 01-07-2018, 12:35 PM
RE: ENG button in Casio calculator - Tyann - 01-07-2018, 05:18 PM



User(s) browsing this thread: 1 Guest(s)