# HP Forums

Full Version: (10C) ABSolute value Function
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
Shouldn't the last step be + not square root?

Pauli
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
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
I was thinking about + removing the 0 from Y.
But since it was an example, it isn't important.
I use the first method ([X^2] [√X]) for the HP 12C.
Reference URL's
• HP Forums: https://www.hpmuseum.org/forum/index.php
• :