(10C) ABSolute value Function
01-08-2019, 06:43 AM (This post was last modified: 01-08-2019 06:45 AM by Gamo.)
Post: #1
 Gamo Senior Member Posts: 738 Joined: Dec 2016
(10C) ABSolute value Function
This little program steps is use for [ABS] the "Absolute Value" function.

This program steps only use "Test Function" while other method use
Arithmetic calculations to get the Absolute Value.

Here is the Arithmetic method: [X^2] [√X]

Test Function method: 0 [X<>Y] [X≤Y] [CHS]

----------------------------------------------------

Example: Program to calculate + or - [√X] using ABS

100 [R/S] display 10

100 [CHS] [R/S] display 10

---------------------------------------------------
Program: Calculate [√X] using ABS to only return positive value
Code:
 0 X<>Y X≤Y CHS √X

Remark: This routine also work on HP-12C

Gamo
01-08-2019, 07:47 AM
Post: #2
 Paul Dale Senior Member Posts: 1,837 Joined: Dec 2013
RE: (10C) ABSolute value Function
Shouldn't the last step be + not square root?

Pauli
01-08-2019, 08:07 AM (This post was last modified: 01-09-2019 01:34 AM by Gamo.)
Post: #3
 Gamo Senior Member Posts: 738 Joined: Dec 2016
RE: (10C) ABSolute value Function
Usually the last line with √X is just the example.
Program without example is
01 0
02 X<>Y
03 X≤Y
04 CHS

That example on line 05 √X
When run any number it will always be positive then use square root.

Gamo
01-09-2019, 03:12 AM (This post was last modified: 01-09-2019 03:14 AM by Gamo.)
Post: #4
 Gamo Senior Member Posts: 738 Joined: Dec 2016
RE: (10C) ABSolute value Function
Example program to demonstrate the use of ABSolute Value.

This program make endless loop to keep subtracting 1 to accumulate
negative value then use ABS to make it positive.

[R/S] display "-1" 1 keep continue ......

Program:
Code:
 01  1 02 STO-0 03 RCL 0 04 PSE 05  0 06 X<>Y 07 X≤Y  08 CHS 09 PSE 10 GTO 01

Gamo
01-09-2019, 04:14 AM
Post: #5
 Paul Dale Senior Member Posts: 1,837 Joined: Dec 2013
RE: (10C) ABSolute value Function
I was thinking about + removing the 0 from Y.
But since it was an example, it isn't important.
01-11-2019, 04:54 AM
Post: #6
 Eddie W. Shore Senior Member Posts: 1,582 Joined: Dec 2013
RE: (10C) ABSolute value Function
I use the first method ([X^2] [√X]) for the HP 12C.
 « Next Oldest | Next Newest »

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