HP Forums
(10C) ABSolute value Function - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: General Software Library (/forum-13.html)
+--- Thread: (10C) ABSolute value Function (/thread-12138.html)

(10C) ABSolute value Function - Gamo - 01-08-2019 06:43 AM

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


Remark: This routine also work on HP-12C


RE: (10C) ABSolute value Function - Paul Dale - 01-08-2019 07:47 AM

Shouldn't the last step be + not square root?


RE: (10C) ABSolute value Function - Gamo - 01-08-2019 08:07 AM

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.


RE: (10C) ABSolute value Function - Gamo - 01-09-2019 03:12 AM

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


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


RE: (10C) ABSolute value Function - Paul Dale - 01-09-2019 04:14 AM

I was thinking about + removing the 0 from Y.
But since it was an example, it isn't important.

RE: (10C) ABSolute value Function - Eddie W. Shore - 01-11-2019 04:54 AM

I use the first method ([X^2] [√X]) for the HP 12C.