Showing posts with label boolean algebra. Show all posts
Showing posts with label boolean algebra. Show all posts

Saturday, June 25, 2022

Retro Review: Hewlett Packard HP 33S

Retro Review:   Hewlett Packard HP 33S








The calculator with the Chevron Keyboard!

Quick Facts

Model:  HP 33S
Company:  Hewlett Packard
Years:  2003-2007
Type:  Scientific
Batteries: 2 x CR-2032
Operating Modes:  RPN, ALG
Memory:  31,277 bytes
Number of Registers: 27, A-Z, i
Display:  2 stack levels

Features

*  standard scientific calculator functions: trig, logs, power, absolute value, integer and fractional part, combinations, permutations, random numbers, hyperbolic functions, and more
*  factorial function that allows real numbers;  Γ(x) = (x - 1)!
*  polar and rectangular conversion functions,  very popular (for good reason) 
*  40 scientific constants
*  8 sets of SI-US conversions
*  base conversions 
*  algebraic mode (which I don't know anyone who would use this calculator in algebraic mode, but it's there)
*  linear regression  (y = mx + b)
*  fraction display mode ( [ ←| ] [ . ] (FDISP))
*  storage and recall arithmetic

We can store equations for evaluation, solving, and integration.  

Full list of conversions:

Polar (→θ,r) - Rectangular (→y,x)
Hours (→HR) - Hours-Minutes-Seconds (→HMS)
Degrees - Radians
Kilograms - Pounds
Degrees Celsius - Degrees Fahrenheit
Centimeters - Inches
Liters - Gallons

Programming

The HP 33S has keystroke programming and the set of commands similar from the HP 32SII:  

*  INPUT var
*  VIEW var  (views the variable without putting the variable's value on the stack)
*  Subroutines and Return
*  Comparison tests between x and 0, x and y.  If the test is true, execute the next step, otherwise skip the next step
*  ISG:  Increment and skip if greater
*  DSE:  Decrement and skip if equal or less than

The HP 33S designates one register, lower case i, for indirect addressing.  The absolute integer value of i determines where storage, recall, label, subroutine, integration variable, exchange, and function designation.  Use (i) to use indirect addressing.  Indirect registers can also access statistical sums:

(i) = 27,  i 
(i) = 28,  n
(i) = 29,  Σx
(i) = 30,  Σy
(i) = 31,  Σx^2
(i) = 32,  Σy^2
(i) = 33,  Σxy

The HP 33S has 26 labels, which restrict programs to 26.  Hence, LBL A instead of LBL A0001.   At first, I didn't like the restriction, but I learned to live with it and don't mind it as much.  

Let's Talk About the Chevron Keyboard

The HP 33S is a unique calculator it's keyboard style:  the keys take a slanted quadrilateral shape, with the center column of keys taking a chevron style shape.   At the top there is a directional pad.  Hewlett Packard took a chance with the design from the standard calculator shape, and it was not a homerun.   

The beginning production of the HP 33S was not successful. Keys had bad responses, the display was not up to par, and some keys are hard to press.   It took Hewlett Packard several production runs to get the keyboard working right, which unfortunately killed the reputation of the HP 33S.  Towards the end of its run, the keyboards were fixed.

I don't mind the unique keyboard, my biggest issue was the spacing the keys where sometimes the shifted functions and alpha characters did not have much space.  This made the keyboard busy.  I also do not like the black arrows on the green and purple backgrounds on the shift keys, I use HP used a lighter font for those arrows.  

A Phoenix of Calculators  

When the HP 33S first hit the market, the calculator was disliked.  Now, it is a sought after calculator.   The original price for the 33S was about $50 US dollars, now if you want one, be prepared to pay at least $75 US dollars, sometimes triple digits.  Make sure you are buying the HP 33S from later in the run (towards 2007).  

Another factor of why the HP 33S is becoming a collector's calculator, the successor, the HP 35S, had several shortcomings such as the number of mathematical bugs and the lack of the rectangular and polar conversion functions.   The HP 33S is closer to the classic style, like the HP 32S and HP 32SII.  

I don't expect to ever be an anniversary edition of the HP 33S but it was an underrated calculator and has its place in calculator history.

Tomorrow I have a list of programs and an integer demonstration.  

Eddie

All original content copyright, © 2011-2022.  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. 



Sunday, April 18, 2021

Swiss Micros DM16L: Advanced Boolean and Factorial (up to 20)

Swiss Micros DM16L:   Advanced Boolean and Factorial (up to 20)


Introduction


The program listing, for the Swiss Micros DM16L and Hewlett Packard HP 16C,  will assign the following functions to the labels:


A:  NAND:   nand(x, y) = not(x and y)

B:  NOR:   nor(x, y) =  not(x or y)

C:  XNOR:  xnor(x, y) = (not x and not y) or (x and y)

D:  Implication:  y → x = (not y) or x

E:  Factorial:  x!  (x is a positive integer up to 20, 64 word size


NAND, NOR, NXOR, and Implication are advanced Boolean functions.  You can check out program code for the HP Prime here:


http://edspi31415.blogspot.com/2020/03/hp-prime-advanced-boolean-functions.html


Program - DM16L/HP 16C


// NAND

001 43,22,A LBL A

002 42,20   AND

003 42,30   NOT

004 43,21   RTN


// NOR

005 43,22,b LBL B

006 42,40   OR

007 42,30  NOT

008 43,21  RTN


// XNOR

009 43,22,C LBL C

010 44,1    STO 1

011 42,30  NOT

012 34      x<>y

013 44,2    STO 2

014 42,30   NOT

015 42,20   AND

016 45,1    RCL 1

017 45,2    RCL 2

018 42,20  AND

019 42,40   OR

020 43,21   RTN


// Implication

021 43,22,d LBL D

022 34      x<>y

023 42,30   NOT

024 42,40   OR

025 43,21   RTN


// Factorial

026 43,22,E LBL E

027 44,32  STO I

028 1      1

029 44,1    STO 1

030 43,22,1 LBL 1

031 45,1    RCL 1

032 45,32   RCL I

033 20      ×

034  44,1    STO 1

035 43,23   DSZ

036 22,1    GTO 1

037 45,1    RCL 1

038 43,21   RTN


Examples


Let:

R1 = 1011 0001

R2 = 1100 1100


Set up: 2-16-0000 (2's complement, 16 bits)


RCL 2, RCL 1, GSB A NAND(R2, R1):  0111 1111*

RCL 2, RCL 1, GSB B NOR(R2, R1): 0000 0010*

RCL 2, RCL 1, GSB C XNOR(R2, R1): 1000 0010*

RCL 2, RCL 1, GSB D R2 → R1:  1100 1110* 

* only the last eight bits 


Set word size to 64:

0 [ f ] [ STO ] (WSIZE)


5 GSB E 5! = 120

9 GSB E 9! = 362880*


* if the word size is insufficient, it will not show 362880 but a weird result as an overflow


12 GSB E   (64 word size)

12! = 4 79001600

Window 1:  4

Window 0:  79001600


20 GSB E

20! = 243 29020081 76640000

Window 2: 243

Window 1: 29020081

Window 0: 76640000


Source for the Advanced Boolean Functions:


John W. Harris and Horst Stocker.  Handbook of Mathematics and Computation Science  Springer:  New York, NY.  2006.  ISBN 978-0-387-94746-4



Eddie


All original content copyright, © 2011-2021.  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. 


Monday, February 15, 2021

Review: Swiss Micros DM16L

Review: Swiss Micros DM16L






Welcome to a special Monday edition of Eddie’s Math and Calculator blog!


General Information


Company:  SwissMicros, https://www.swissmicros.com

Type:  Programmable Scientific - Boolean Algebra

Memory: 203 steps, shared with memory registers; 32 MB external flash

Battery:  CR 2032

Connection:  USB-B

Cost:  119 CHF, about $132.38 USD (2/5/2021)

Current Software Version:  DM16_31, 7/21/2020

Case Included?  Yes

Operating System: RPN (Reverse Polish Notation)


A Programmer’s Paradise

The Swiss Micros DM16L, and it’s small version, the DM16, is a clone of the highly popular and sought after Hewlett Packard HP 16C.  The functions are suited to computer science, including:


One key conversions between Hexadecimal (base 16), Octal (base 8), Decimal (base 10), and Binary (base 2) integers.  


Boolean features including AND, OR, NOT,  XOR


Bit shift and rotating functions, masking bits, and double division, remainder, and multiplication


There is a separate floating point arithmetic mode, separate from decimal integer mode.


You can customize integers up to 64 bits by the WSIZE function.  A handy shortcut is to set integers up to 64 bits is done by the key sequence:  0 [ f ] [ STO ] (WSIZE)


Negation of integers are determined by one of three modes:  1’s Complement, 2’s Complement, and Unsigned Numbers.    


If that isn’t enough, you can manipulate and test specific bits with the SB (set bit), CB (clear bit), and B? (is the bit set) commands. 


The STATUS command gives the user a three number status #-##-####. 


The first number is the complement mode:  0 for unsigned, 1 for 1’s complement, 2 for 2’s complement.


The second number is the current wordsize, from 1 bit to 64 bits.


The third number is the status of the four user flags 0 to 3, in descending order (flag 3, flag 2, flag 1, flag 0):  0 for clear, 1 for set.  The user flags are used in programming.


Programming


If you have programmed on the original HP-16C, then you would be right at home programming with the DM16L, with all the key codes and positions intact.   There are eight comparison tests available:  x≤y, x<0, x>y, x>0, x≠y, x≠0, x=y, x=0.   Up to 16 labels can be used, labels 0-F.  The special registers I and (I) are used for indirect storage and branching.   The DSE and ISZ use register I.


Curiously missing is storage arithmetic.   For example, instead of STO+ #, the following sequence of commands must be used:  (number), RCL #, +, STO #.  


Sample Programs


Integer Division:  Quotient and Remainder


001 LBL A         43,22,A

002 STO 0 44,0

003 X<>Y 34

004 STO 1 44, 1

005 X<>Y 34

006 ÷ 10

007 R/S 31

008 RCL 1 45, 1

009 RCL 0 45, 0

010 RMD 42, 9   \\ remainder command

011 RTN 43, 21


Example:  Word size = 16


Decimal Integer Mode (DEC):   41 / 7 = 5, remainder 6

Y:  41, X:  7 [ GSB ] [ A ]

Result:   5, [ R/S ], 6


Hexadecimal Integer Mode (HEX):  FE2 / 81 = 1F, remainder 43

Y:  FE2, X: 81 [ GSB ] [ A ]

Result:  1F, [ R/S ], 43


Adding Both the 1’s and 2’s Complement


001 LBL B 43, 22, B

002 STO 1 44, 1

003 Set 1’s 42, 1

004 CHS 49

005 STO 0 44, 0

006 RCL 1 45, 1

007 Set 2’s 42, 2

008 CHS 49

009 RCL 0 45, 0   // storage arithmetic is not available

010 + 40

011 STO 0 44, 0

012 RTN 43, 21


Examples:  Word Size = 8


Hexadecimal Integer Mode (HEX)

x = 2D

Result:  A5  (D2 + D3)


Hexadecimal Integer Mode (HEX)

x = F6

Result:  13  (9 + A)


Remember: Word size is important, as your mileage may vary.  


Verdict

Swiss Micros continues to manufacture quality calculators.  Due to the rarity and highly sought after HP 16C, the price to obtain one may be out of reach.  The DM16L is a much more affordable alternative.  The calculator is solid, keys feel great, and the added connectivity is an added bonus.  


Eddie


All original content copyright, © 2011-2021. 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. 


Saturday, April 25, 2020

HP 42S/DM42/Free 42: Advanced Boolean Functions

HP 42S/DM42/Free 42: Advanced Boolean Functions

Introduction

The programs NOTBIT, NAND, NOR, and IMPL are four advanced Boolean functions that work on Binary Numbers.  You designate a bit size, up to 35, on each of these functions.   There is no signed bit in these programs.  Results are stored in the Alpha Register while the decimal equivalent is stored in the X register. 

HP 42S/DM42/Free 42 Program:  NOTBIT

00 { 57-Byte Prgm }
01▸LBL "NOTBIT"
02 "BIT SIZE?"
03 PROMPT
04 STO 00
05 BINM
06 "BIN?"
07 PROMPT
08 STO 01
09 DECM
10 2
11 RCL 00
12 Y↑X
13 X<>Y
14 BASE-
15 1
16 BASE-
17 BINM
18 "NOT: "
19 ARCL ST X
20 AVIEW
21 EXITALL
22 .END.

Example:

NOT 11011, bit size:  8

Result: 
NOT:  11100100

HP 42S/DM42/Free 42 Program:  NAND

a NAND b = NOT ( a AND b )

00 { 67-Byte Prgm }
01▸LBL "NAND"
02 "BIT SIZE?"
03 PROMPT
04 STO 00
05 BINM
06 "BIN1?"
07 PROMPT
08 STO 01
09 "BIN2?"
10 PROMPT
11 STO 02
12 AND
13 DECM
14 2
15 RCL 00
16 Y↑X
17 X<>Y
18 BASE-
19 1
20 BASE-
21 BINM
22 "NAND: "
23 ARCL ST X
24 AVIEW
25 EXITALL
26 .END.

Example:

110011 NAND 111100, bit size: 8

Result:
NAND:  11001111

HP 42S/DM42/Free 42 Program:  NOR

a NOR b = NOT ( a OR b )

00 { 64-Byte Prgm }
01▸LBL "NOR"
02 "BIT SIZE"
03 PROMPT
04 STO 00
05 BINM
06 "BIN1?"
07 PROMPT
08 STO 01
09 "BIN2?"
10 PROMPT
11 STO 02
12 OR
13 DECM
14 2
15 RCL 00
16 Y↑X
17 X<>Y
18 BASE-
19 1
20 BASE-
21 BINM
22 "NOR: "
23 ARCL ST X
24 AVIEW
25 EXITALL
26 .END.

Example:

110011 NOR 111100, bit size: 8

Result:
NOR:  11000000

HP 42S/DM42/Free 42 Program:  IMPL

IMPL (Implication):  a → b = (NOT a) OR b

00 { 66-Byte Prgm }
01▸LBL "IMPL"
02 "BIT SIZE?"
03 PROMPT
04 STO 00
05 BINM
06 "BIN1?"
07 PROMPT
08 STO 01
09 DECM
10 2
11 RCL 00
12 Y↑X
13 X<>Y
14 BASE-
15 1
16 BASE-
17 BINM
18 "BIN2?"
19 PROMPT
20 STO 02
21 OR
22 "A→B: "
23 ARCL ST X
24 AVIEW
25 EXITALL
26 .END.

Example:

110011 IMPL 111100, bit size: 8

Result:
IMPL:  11111100

You can download the raw files here: 
https://drive.google.com/open?id=19u8tPcX4_-o0lwvjUc0KO4-WSmhnxpwe

Source:

John W. Harris and Horst Stocker  Handbook of Mathematics and Computation Science  Springer:  New York, NY.  2006.  ISBN 978-0-387-94746-4

Eddie

All original content copyright, © 2011-2020.  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.

Friday, March 27, 2020

Review: Victor 930-2 Scientific Calculator

Review:  Victor 930-2 Scientific Calculator



Quick Facts:

Model:  Victor 930-2
Company:  Victor
Type:  Scientific
Years:  2008 to present
Display:  10 digits
Batteries:  Solar with battery backup (LR43/LR1130)
Retail Price:  $17.99
Logic:  Algebraic, AOS
Number of Functions:  154

Product website from Victor:  https://www.victortech.com/product/930-2

Powerful One Line Calculator - The 21st Century Version of the TI-34



The Victor 930-2 calculator has the following features:

*  Trigonometric functions and their inverses
*  Rectangular/Polar Conversions
*  Degrees/Degree-Minute-Second Conversions
*  Logarithms, Power, Exponential
*  Single Variable Statistics
*  Base Conversions with Boolean Functions (AND, OR, XOR, XNOR, NOT)
*  Constant Calculations
*  Fractions

The keys have the same mapping as the original Texas Instruments (one line) TI-34 from the 1980s and 1990s.   There are some keys and functions that are labeled differently:

Victor 930-2:  [ X→M ],   TI-34:  [ STO ]
Victor 930-2:  [ M+ ], TI-34:  [ SUM ]
Victor 930-2:  [ X←→M ], TI-34:  [ EXC ]
Victor 930-2:  [ INV ],  TI-34:  [ 2nd ]
Victor 930-2:  [ DATA ], TI-34:  [ ∑+ ]
Victor 930-2:  [ DEL ], TI-34: [ ∑- ]

The Victor 930-2 has a bigger and clearer numeric display and an on-off switch. 

Constant calculations is something that might be an overlooked feature on some of these calculators, so let's take a look at how it works.  This applies to both the Victor 930-2 and the TI-34. 

Constant Calculations

For selected two argument functions, you can repeat the calculations on the second argument by entering different values and pressing the equals button [=]. 

A  (op)  B [ = ]
C [ = ]    ( C op B )
D [ = ]    ( D op B )
...

op:  +, -, ×, ÷, y^x, x√y, AND, OR

Example 1:
f(x) = x × π,  x = 4, 3, 3.8

4 [ × ] [ INV ] [ EXP ] (π) [ = ]
Result:  12.56637061

3 [ = ]   ×π is stored in memory
Result:  9.424777961

3.8 [ = ]
Result:  11.93805208

Example 2:
f(x) = x^2.5, x = π, 10.2, e

[ INV ] [ EXP ] (π) [ y^x ] 2.5 [ = ]
Result:  17.49341833

10.2 [ = ]     ^2.5 is stored in memory
Result:  332.2771137

1 [ INV ] [ LN ] (e^x) [ = ]
Result:  12.18249396

Example 3: 
B can be a multi-step in constant calculations.

f(x) = x ÷ (4^2 + 3), x = 10, 20, 50

10 [ ÷ ] [ ( ] 4 [ x^2 ] [ + ] 3 [ = ]
Result:  0.526315789

20 [ = ]    ÷(4^2 + 3) or ÷19 is stored in memory
Result:  1.052631579

50 [ = ]
Result:  2.631578947

Fractions

You can enter fractions and calculate with fractions.  However, you can only convert between fractions and decimals if you start with fractions in your calculations.  The calculator has a limit of 10 digits between the whole part, numerator, and denominator. 

Keyboard

The keyboard is OK.  I like the contrast between the black background and the font better on the Victor 930-2. 

I am irked by the protective case, as it is difficult to take the hard shell case off once the calculator is locked in place.  I prefer the slide case of the TI-34.  I may not cover the 930-2 and use a case or the box to protect the calculator. 

Verdict

If you are looking for a TI-34, consider the Victor 930-2 as it is an updated version.  It does the job.  Again, I wish the hard shell case was easier to work with. 

Eddie

All original content copyright, © 2011-2020.  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.

Sunday, March 8, 2020

HP Prime: Advanced Boolean Functions

Advanced Boolean Functions





This is a collection of advanced Boolean functions and how you can do this on a scientific calculator that has base conversions and Boolean functions (and, or, not).   One thing to keep in mind is that Boolean functions on a scientific calculator assume that you are working with a set bit size.

Order of Operations:  Parenthesis, NOT, AND, OR

For the examples below, I am going to work with only 8 bit size binary integers, and display the last 8 bits (rightmost 8 digits in Binary numbers).   For all examples, let (in base 2):

A = 1100 1010
B = 1110 0011

Like the Boolean functions and, or, and not, these functions work on each bit (0s and 1s) of the binary form of the number.

Integer Types on the HP Prime

On the HP Prime, the integer type is used for Boolean function calculations.  Symbolize integer types by preceding it by a hashtag # and designated a letter at the end of the integer:  b for binary, o for octal, d for decimal, and h for hexadecimal.

Example:  #11010b  represents the binary number 11010.

You can specify the bit size, from 1 to 64, by attaching a colon and bit size in between the integer and it's indicator.

Example:  #11010:8b represents the 11010 in an 8-bit format.  You can specify the default size in the Home Settings.

NAND (Not And)

The function NAND is also known as the Shaffer function.

nand(A, B) = not(A and B)

nand(1100 1010, 1110 0011) = not(1100 1010 and 1110 0011) = 0011 1101

Truth Table - NAND
0 nand 0 = 1
0 nand 1 = 1
1 nand 0 = 1
1 nand 1 = 0

HP Prime Program:  NAND

EXPORT NAND(a,b)
BEGIN
// not and Boolean Function
RETURN  NOT (a AND b);
END;

Syntax:  NAND(a,b)

NOR (Not Or)

The function NOR is also known as the Peirce function.

nor(A, B) = not(A or B)

nor(1100 1010, 1110 0011) = not(1100 1010 or 1110 0011) = 0001 0100

Truth Table - NOR
0 nor 0 = 1
0 nor 1 = 0
1 nor 0 = 0
1 nor 1 = 0

HP Prime Program:  NOR

EXPORT NOR(a,b)
BEGIN
// not or Boolean Function
RETURN  NOT (a  OR  b);
END;

Syntax:  NOR(a,b)

XOR (Exclusive Or)

Note:  some calculators will have the XOR function

xor(A, B) = (A or B) and (not A or not B)

xor(1100 1010, 1110 0011)
= (1100 1010 or 1110 0011) and (not 1100 1010 or not 1110 0011)
= 0010 1001

Truth Table - XOR
0 xor 0 = 0
0 xor 1 = 1
1 xor 0 = 1
1 xor 1 = 0

Equivalence (←→), XNOR

A ←→ B = (not A and not B) or (A and B)

1100 1010 ←→ 1110 0011
= 1100 1010 xnor 1110 0011
= (not 1100 1010 and not 1110 0011) or (1100 1010 and 1110 0011)
= 1101 0110

Truth Table - ←→, xnor 
0 xnor 0 = 1
0 xnor 1 = 0
1 xnor 0 = 0
1 xnor 1 = 1

HP Prime Program XNOR

EXPORT XNOR(a,b)
BEGIN
// equivalence, XNOR
RETURN (NOT a AND NOT b) or (a AND b);
END;

Syntax:  XNOR(a, b)

Implication (→)

A → B = (not A) or B

1100 1010 → 1110 0011
= (not 1100 1010) or 1110 0011
= 1111 0111

Truth Table -  Implication, →
0 → 0 = 1
0 → 1 = 1
1 → 0 = 0
1 → 1 = 1

HP Prime Program:  IMPL

EXPORT IMPL(a,b)
BEGIN
// implication
RETURN (NOT a) or b;
END;

Source:

John W. Harris and Horst Stocker.  Handbook of Mathematics and Computation Science  Springer:  New York, NY.  2006.  ISBN 978-0-387-94746-4

Eddie

All original content copyright, © 2011-2020.  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.

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...