HP Forums

Full Version: (12C) and (41C) Rounding
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Introduction

The following program rounds positive numbers to the desired decimal amount of places. For example, √3 rounded to 3 places is 1.732. e^2 rounded to 2 places is 7.39.

Set up your stack like this:
Y: number
X: number of decimal places

HP 12C Program: Rounding

Step; Code; Key
Code:
01;  1;  1
02;  0;  0
03;  34;  x<>y
04;  21;  y^x
05;  36;  ENTER
06;  33;  R↓
07;  20;  *
08;  36;  ENTER
09;  43,24;  FRAC
10;  40;  +
11;  43, 25;  ITNG
12;  33;  R↓
13;  33;  R↓
14;  33;  R↓
15;  10;  ÷
16;  43,33,00;  GTO 00

HP 41C Program: Rounding

Code:
01  LBL^T ROUND
02  10↑X
03  STO T
04 *
05 ENTER↑
06 FRC
07 +
08 INT
09 R↑
10 /
11 RTN
12 END

Round √3 rounded to 3 places

Y: 3, sqrt (√3)
X: 3

Result: 1.732

Round e^2 rounded to 2 places. is 7.39.

Y: 2, e^x (e^2)
X: 2

Result: 7.39
Reference URL's