Showing posts with label if-then-else. Show all posts
Showing posts with label if-then-else. Show all posts

Sunday, November 5, 2023

Retro Review: Sharp PC-1248

Retro Review:  Sharp PC-1248





Quick Facts


Model:  PC-1248

Company:  Sharp

Years:  circa 1986, years of production unknown

Type:  Scientific, Pocket Computer

Power:  2 x CR-2032 batteries

Display:  1 line, 16 characters

Programming Language:  BASIC

Memory:  7,422 bytes


Program and Run


The Sharp PC-1248 is a credit card sized BASIC pocket computer, which is stored in a slip on hard case.  The screen is one line, containing up to 16 characters.  


There is one program space, allowing for line numbers from 1 to 999.   The range of commands are adequate for general mathematical applications.  


There are several peripherals available for PC-1248, including a printer and a cassette tape recorder to save and load programs.


Sharp also produced the PC-1246S pocket computer around the same time, only with memory capacity of 1,278 bytes.  


PC-1248 vs EL-5500 III




The PC-1248 operates similarly to the Sharp EL-5500 III pocket calculator; though it lacks the statistics mode and matrix operations.    I reviewed the EL-5500 III in 2017:  https://edspi31415.blogspot.com/2017/01/retro-review-sharp-scientific-computer.html



Keyboard:  It Could Have Been Better


To be honest, the keys are pretty hard to press.   I used a q-tip to press the keys at first when a soft-like stylus did not work.  However, the keys does have button under the keyboard.  This is the biggest complaint I have with the PC-1248.



Final Thoughts


I like the form factor of the PC-1248, and the command set is good for quick calculations on the run.   The computer is to the point, basic programming.   As I mentioned, the keys could have been better.   



Sample Programs for the PC-1248


Math Statement Builder: RUN 40


40 PAUSE "MATH STMT BUILD"

42 A = RND 21-1

44 B = RND 21-1

46 C = RND 21-1

48 D = A*B+C

50 PRINT A; "*"; B; "+''; C; "="; D:  END


Examples:  (results will vary)


4. * 3. + 7. = 19.


13. * 16. + 2. = 210.


2. * 8. + 3. = 19.


Net Present Value: RUN 60


60 PAUSE "NET PRESENT VALUE": CLEAR

62 INPUT "CF0:"; N, "RATE:"; I

64 J=1

66 INPUT "FLOW:"; F, "FREQ:"; K

68 FOR L=1 TO K: N=N+F/(1+I/100)^J: J=J+1

70 NEXT L

72 INPUT "MORE=1"; L

74 IF L=1 THEN 66

76 PRINT USING "########.##"; "NPV:"; N

78 END


Examples:


CF0:  -5000

CF1:   3000, frequency 1

CF2:  6000, frequency 1

Rate: 3%


Result:  NPV = 3568.20


CF0: -5000

CF1: 500, frequency 12

CF2:  0, frequency 6

CF3:  1000, frequency 6

Rate:  2.95%


Result:  NPV = 3207.18 



Future Value:  Continuing Compound Interest:  RUN 110


110 PAUSE "FV - CONT. CMPD. INT.": CLEAR

112 INPUT "PV? "; P

114 INPUT "RATE? "; R:  R=R/100

116 INPUT "YEARS? "; T

118 F=P*EXP(R*T)

120 PRINT USING "########.##"; "FV = "; F

122 END


Examples:


P = 5000, R = 5, T = 5.   Result:  F = 6420.12


P = 1000, R = 6, T = 20.  Result:  F = 3320.11


Source


"The Sharp PC-1246 computer":  http://pocket.free.fr/html/sharp/pc-1246s_e.html

"The Sharp PC-1248 computer": http://pocket.free.fr/html/sharp/pc-1248_e.html

The pocket computer museum.   1999-2022.  

Retrieved October 12, 2023.  


Eddie


All original content copyright, © 2011-2023.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author. 


Wednesday, April 12, 2023

Review: Casio fx-991CW (and the lack of multi-statements)

Review:  Casio fx-991CW (and the lack of multi-statements)







Quick Facts


Model:  fx-991CW

Company:  Casio

Years:  Internationally: 2022 - present, United States: April 2023 - present

Type:  Scientific

Power:  Solar with 1 LR44 backup battery

Display:  Multiline, 4-color gray display

Original Price:  $21.00 - $22.99 U.S. Dollars, varies on the specific version

Number of Variables:  9

Operating System: Algebraic



Update on the Classwiz


The fx-991CW is an update in Casio's Classwiz series, specifically on the 2015 fx-991EX Classwiz.  


Check out my review on the fx-991EX Classwiz from November 2015 here:

http://edspi31415.blogspot.com/2015/11/casio-fx-991ex-classwiz-review.html


The modes on the Classwiz are:


Calculate:  the main app for mathematical calculations


Statistics:  1 to 2 variable statistics.  Regressions include:

Linear:  y=a+bx

Quadratic: y=a+bx+cx^2

Logarithmic:  y=a+b*ln(x)

Exponential:  y=a*e^(bx)

Power I:  y=a*b^x

Power II: y=a*x^b

Inverse:  y=a+b/x


Distribution:  Calculations involving the binomial, normal, and Poisson.  The Inverse Normal deal with the lower tail (left) probability only.  


Spreadsheet:  Like the fx-991EX and Casio's current graphing calculators, the fx-991CW has a spreadsheet which has a 5 x 45 cell capacity.  The total memory is increased to 2,380 bytes (from 1,700 bytes on the fx-991EX).  Basic spreadsheet features included are:  labeling cells, sum, mean, minimum, maximum, absolute cell references ($), copy, cut, and paste.  


Table:   Generate a table of one function or two functions.   The functions are defined as f(x) and g(x).  With a QR code, you can generate a graph of these functions.


Equation:   Solve linear systems, up to 4 x 4 equations.  Solve polynomials, up to 4th order.  Real coefficients only but complex roots are calculated.   The general equation solver is moved to this mode.   


Inequality:  Solve inequalities up for polynomials of orders 2, 3, and 4.


Complex Number:  Complex number arithmetic with polar/rectangular conversion, integer powers, real/imaginary parts, conjugate


Base N:  Integer arithmetic with Boolean logic.  Instead of keys, the [FORMAT] key cycles through the four modes: Decimal, Hexadecimal, Binary, Octal.   Binary integers are up to 31 bytes with 1 sign bit.  We can not store or recall varaible values in this mode.


Matrix:  Works with four matrices up to 4 rows and 4 columns.  Functions include transpose, inverse, and determinant.


Vector:  Works with 4 vectors with either 2 or 3 elements.  Functions include dot product, norm, and cross product.


Ratio:  Solves common ratio problems.


Math Box:  This is the a new feature to the Classwiz.   For the United States, the Math Box has two simulations:  Dice Rolls and Coin Toss.   Depending on the country, the CW may include additional features.  



Emulator and Classpad.net


Purchasing a fx-991CW came with a emulator license with ClassPad.net.   The license number can be obtained using the Get Started option from the Settings menu.   Use the QR code.  For my calculator, the license for using ClassPad.net is seven years at no cost.  However, using an emulator without first purchasing an eligible calculator will require an additional cost.  


You can find details about Classpad.net here:  https://classpad.net/intl/features/



Keyboard, What is Added, and What is Subtracted





The keyboard of the fx-991CW is quite different from the previous Casio calculators.   The keys are now round with a lot less labels.   Most of functions are now stored in the catalog and tools.  Let's go over some of these keys:


[ house icon ]: [HOME].   This is where we switch the modes of the fx-991CW.   There are no numerical shortcuts, so we have to arrow and scroll to select the mode we want.  


[ three lines ]: [SETTINGS].  The settings key replaces the SETUP key sequence.   

Also note that the sub menus are selected by either pressing [ → ] or [ EXE ].  If there are radio buttons, select the option desired.  


[ curved arrow ]: [EXIT/EDIT].  This key, on the 2nd row, 2nd key from the left, will be used to exit menus and re-edit expressions.   


[ double up arrow ]/[ double down arrow ]:  This key, top right of the calculator, is used to quickly scroll through menus or lists.  Think of this key as the Page Up/Page Down key.


[ < >x] ]/[VARIABLE]:  This is the variable key.



Here is where we will store and edit values that are stored in each of the nine variables.   This key replaces the STORE key.     If we are operate in a mode that does not allow for editing or store values, there will be a lock icon with the selected variable.  


To store a result:

1.  Execute operation or recalling a calculated stat variable.

2.  Press [VARIABLE].

3.  Select variable, press [ OK ].

4.  Select Store, press [ OK ].


To edit a variable's value:

1.  Press [VARIABLE].

2.  Select variable, press [ OK ].

3.  Select Edit, press [ OK ].

4.  Enter the new value, press [ OK ].


To recall a variable in a calculation:

1.  Press [ SHIFT ].

2.  Press any of the following keys to get the variable:

[ 4 ]:  A

[ 5 ]:  B

[ 6 ]:  C

[ 1 ]:  D

[ 2 ]:  E

[ 3 ]:  F

[ 0 ]:  x

[ . ]:  y

[ x10^ ]:  z


There is no ALPHA key as it was in past Casio calculators.  


[ f(x) ]/[FUNCTION]:  



Here is where we can store and use up to two functions: f(x) and g(x).  The great news is that f(x) and g(x) are no longer limited to the Table, they can be used in other modes such as Calculate.   The equations f(x) and g(x) are retained while switching modes but not retained when the calculator either is turned off or the Input/Output setting is changed.  A missed opportunity for the latter.


A plus is that either f(x) or g(x) can be a composite function.  That is f(x) can contain g(x) or g(x) can contain f(x).  


There are two ways to access the x variable:  its own key [ x ] or the key sequence [ SHIFT ] [ 0 ].  


[book]/[CATALOG]:  This is where all the functions and commands can be accessed.  The menu order of the catalog changes depending on the mode used.  Some submenus include:


Function Analysis:  The calculus functions, that used to be on the keyboard, are now stored in the Function Analysis menu:  derivative, integral, summation, logarithm*, log*, ln* (* also on the keyboard)


Probability:   % (divides the number by 100), factorial, permutation, combination, random number, random integer


Numeric:  Absolute Value, Round Off (round the number to the Fix settings internally)


Angle/Coord/Sexa...:  angle units (degrees, radians, grads, degrees minutes seconds*), polar/rectangular conversions (* also on the keyboard)


Sci Constants:  47 scientific Constants


Unit Conversions


[ three circles ]/[ TOOLS ]:  The TOOLS menu changes dynamically based on the mode.   For example, the Calculate mode will have an Undo function.


[ FORMAT ]:  Instead of the [S<=>D] key, we have the [FORMAT] key, which asks how to change the value:  Standard, Decimal, Improper Fraction, Mixed Fraction,  ENG (Engineering) Notation, Sexagesimal (degrees-minutes-seconds).


In Base mode, the [ FORMAT ] key toggles between the four bases (decimal, hexadecimal, binary, octal).


I did three comparison speed tests between the fx-991CW and fx-991EX  here:  https://www.youtube.com/watch?v=cj0Odnv0Mwk


As I understand, the fx-991CW has a faster processor than the previous fx-991EX.



Now let's talk about what is subtracted in this update.  You read this correctly, several features did not make it from the fx-991EX to the fx-991CW:


The  CALC feature where we could type in a formula, press [ CALC ] and have formula evaluation.  I was not able to find the CALC feature on the fx-991CW.


There is no longer the independent memory M, nor the storage arithmetic functions M+ and M-.  I miss this feature the most.  I really wish scientific and graphing calculators in general embrace store arithmetic like Hewlett Packard and Swiss Micros.


There is no longer the ability to use multi-statement expressions, with each expression separated with a colon.  Even when it was available, (1) storing results immediately terminated the expression (forcing the use of Ans and when available, PreAns to make using results in the next part possible), and (2) when replayed, the statement was broken up into separate parts.  


Addendum 


Note (4/12/2023):  I am wrong when I said that storing results in multi-statements on the fx-991EX (not the fx-991CW) is impossible.  We use the equals key ([ALPHA] ( = )), as in this example:


A = 9 : B = 8 * A


Csaba Tizedes uses the multi-statement and CALC feature on the fx-991EX to create an IF-THEN-ELSE structure.  In this video Tizedes uses this structure to solve equations using the Bisection method.  The IF-THEN-ELSE structure tests whether a number is positive or negative.  Please take a look his video:


https://www.youtube.com/watch?v=umxScZL1V6A


Gratitude to Csaba Tizedes, this video is shared with his permission.  



Final Thoughts


Overall, the fx-991CW is pretty solid calculator with a readable screen and a lot of features.  My favorite part of the updated is the ability to use the functions f(x) and g(x) outside of the table function.  I also like the catalog key and the page up/page down key.


I get that Casio is going for a simpler, non-busy keyboard.  However, I prefer a separate ALPHA key, along with a STORE key: it's the most efficient way to store variables.   A consequence of a non-busy keyboard is that a lot of the commands can only be accessed through menus.  The ALPHA key could have freed nine keys for more common shifted keys such as x!, polar/rectangular conversions, etc.   I would have liked to see a couple of customizable keys where we can store commands, which could be the shift of the multiplication and division keys.  The financial calculator FC-200V has two slots to store commands.


The faster processor and the better screen are pluses.  You will still get a lot for the money spent on the fx-991CW. 


Caveat:   However, if you want, need, or require subtracted features described above (CALC feature, independent memory, multi-statement expressions), you are better off buying the former fx-991EX or a fx-115ES Plus 2nd Edition.  


Unfortunately, removing the multi-statement, Casio sapped it's algorithmic power with the fx-991CW, and it needs to come back.  Furthermore, please put integer part, fraction part, and sign functions.   


Eddie


All original content copyright, © 2011-2023.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author. 


Wednesday, April 4, 2018

HP Prime Programming Tutorial is now available


HP Prime Programming Tutorial is now available

The HP Prime Programming tutorial is a set of twelve tutorials designed to get up and running on HP’s PPL programming language.  Knowledge of the programming language will help you take your HP Prime further.  The topics covered are:

1.  Help Key, Local Variables, RETURN command
2.  Message box, IF-THEN-ELSE structure, FOR loop
3.  WHILE loop, REPEAT loop, Detecting key presses
4.  CHOOSE command (providing a pop-up menu), CASE structure
5.  Colors, Switching Apps
6.  Subroutines
7.  Drawing Graphics, Cartesian vs Pixel Coordinates
8.  Drawing Lines, Polygons, Arcs, Circles
9. Numerical Calculus
10. Using App Functions in Programs
11. Drawing and using a soft menu
12. Creating custom apps

Firmware Version 13441



A little history

If you want to look at my original tutorial series that posted during October through December 2013, the first of the series is here: https://edspi31415.blogspot.com/2013/10/hp-prime-programming-tutorial-1-local.html 

However, the HP Prime’s firmware had a lot of updates since then.  And the PDF file has more topics and is up to date. 

On the date of this entry, this blog is one week away from its 7th Anniversary.  This blog’s “birthday” is April 11.  I want to thank you all for your support and compliments, this is labor of love for. 

Enjoy!

Eddie

All original content copyright, © 2011-2018.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.  Please contact the author if you have questions.

Thursday, October 6, 2011

RPL Programming Tutorial - Part 3 - HP 49g+/50g: If-Then-Else

If Only...

Welcome to Part 3 of the RPL Programming Tutorial with the HP 49g+ and HP 50g calculator. To recap, Part 1 discussed the basics of RPL programming and Part 2 introduced the concept of local variables.

In Part 3 we will dive into the IF-THEN and IF-THEN-ELSE structures. These structures test data against a condition, and then instructs the machine to execute designated program code based on the results.

In general, an IF-THEN-ELSE-END structure looks like this:

IF condition listed here (i.e. x = 5, y > 10, z ≤ 0, a ≠ b, etc.)
THEN commands to be done if the condition is true
ELSE commands to be done if the condition is false
END

How to find the IF menu

You can input the IF, THEN, ELSE, and END program commands separately. However, the HP 50g (and 49g+) gives the user another choice. With a keystroke sequence, you can enter the entire sequence as a template.

To insert the templates:

Start by pressing [LS] [EVAL] (PRG) [F3] (BRCH) .

To insert an IF-THEN-END structure, press [LS] [F1] (IF).

To insert an IF-THEN-ELSE-END structure, press [RS] [F1] (IF).

The next two programs will show an example of each of the two structures.

The Online Shipping Deal

A famous online store is running a promotion: Order at least $100.00 from our store, and we'll pay the $5.95 shipping fee! This program calculates the total amount of the order, with shipping if any. Assume the store charges 7.5% sales tax on all orders including shipping.

Notes:
1. The local variable A will be used to designate the amount of goods purchased.
2. Since A + y% = A + x * y /100 = A * (1 + y /100), we will multiply the amount plus shipping by 1.075. (Let y = 7.5%)
3. The $5.95 shipping charge applies only when the order amount is less than $100.00. Set up the test this way: If A < 100, add 5.95 to A, otherwise do nothing. Because we are only executing further instructions only when the condition is true, no ELSE command is necessary.

The Program ONSALE

Comments will be italicized, starting with an asterisk. This program assumes that the purchase amount is on Level 1 of the stack.

[RS] [ + ] (<< >>)
* Start of the program
[RS] [ 0 ] (&rarr)
[ALPHA] [F1] (A)

* Assign the amount to the local variable A
[RS] [ + ] (<< >>)
* Start the main program
[ALPHA] [F1] (A)
* Call A to the stack
[LS] [EVAL] (PRG)
[F3] (BRCH)
[LS] [F1] (IF)

* Insert the IF-THEN-END structure
[ALPHA] [F1] (A)
[SPC] 100 [RS] [ X ] (<)

* Insert the test condition A < 100
[ &darr ] (down arrow)
5.95 [ + ]

* Add shipping charge if A < 100
[ &darr ] 1.075 [ x ] [RS] [ENTER] (&rarr NUM) [ENTER]
* Finish the program

[ ' ] [ALPHA] [ALPHA] [ ' ] (O) [EVAL] (N) [SIN] (S) [F1] (A) [NXT] (L) [F5] (E) [ENTER] [STO>]

The completed program ONSALE:
<< &rarr A << A IF A 100 < THEN 5.95 + END 1.075 * &rarr NUM >> >>

Instructions:
1. Enter the amount on Level 1 of the stack.
2. Run ONSALE.

Test Data:

Input = 50, Result = 60.14625 (A $50.00 order results in a total bill of $60.15.)

Input = 99.99, Result = 113.8855 (A $99.99 order results in a total bill of $113.89)

Input = 100, Result = 107.5 (A $100.00 order results in a total bill of $107.50. Surprised? Remember all orders $100.00 or more result in the shipping charged being waived.)

Input = 149.99, Result = 161.23925 ($149.99 order yields a bill of $161.24)

f(x) = (sin x)/x

This program calculates the function f(x) = (sin x)/x for all real numbers. If we attempt to calculate f(0) directly, we would get a "division by zero" error. However, the calculus limit as f(x) approaches 0 is 1. Let's create a test condition that detects for an input of 0. If the input is anything else, f(x) computes normally.

Note: The test of equality requires two equal signs, ==. This can be typed directly from the keyboard via alpha or by the TEST submenu of the PROGRAM menu. This program uses TEST submenu method (4 keystrokes opposed to 6 keystrokes).

The Program SINX

The program takes X from Level 1 of the stack and stores it as the local variable X.

[RS] [ + ] (<< >>)
[RS] [ 0 ] (&rarr)
[ X ]

* Stores the contents of Level 1 in the local variable X
[RS] [ + ] (<< >>)
[LS] [EVAL] (PRG)
[F3] (BRCH)
[RS] [F1] (IF)

* Inserts the IF-THEN-ELSE-END structure
[ X ] [SPC] 0
[LS] [EVAL] (PRG) [F4] (TEST) [F1] (==)

* Inserts the double equals sign, ==, for the equality test. Test X = 0?
[ &darr ] [SPC] 1
* Enters the commands should X = 0 (THEN)
[ &darr ] [SPC]
[ X ] [SIN] [ X ] [ ÷ ]
[RS] [ENTER] (&rarr NUM)

* Enters the commands should X ≠ 0 (ELSE)
[ENTER]
* Terminates program entry

[ ' ] [ALPHA] [ALPHA] [SIN] (S) [TOOL] (I) [EVAL] (N) [ X ] (X) [ENTER] [STO>]

The complete program:
<< &rarr X << IF X 0 == THEN 1 ELSE X SIN X / &rarr NUM END >> >>

Source: HP 48SX Scientific Expandable Calculator: Owner's Manual Volume II. Hewlett Packard, 3rd Edition, 1990

Instructions for SINX:
1. Enter X on the stack.
2. Run SINX.

Test Data - Assume the calculator is in Radians mode:

Input = -1, Result = 0.841470984808

Input = 0, Result = 1 (If you get this, then the IF-THEN-ELSE-END structure worked)

Input = 1, Result = 0.841470984808

Coming up, we'll take a look at the FOR-NEXT structure. See you next time in Part 4!

Eddie


This tutorial is property of Edward Shore. Mass reproduction or distribution requires express permission of the author.

DM42 and HP 42S: Quadratic Equation, Characteristic Polynomial, and Eigenvalues

DM42 and HP 42S: Quadratic Equation, Characteristic Polynomial, and Eigenvalues The programs are listed for the Swiss Micros DM42 an...