Rounding to the Nearest Reciprocal
|
11-26-2017, 09:10 PM
(This post was last modified: 11-28-2017 04:17 AM by Eddie W. Shore.)
Post: #1
|
|||
|
|||
Rounding to the Nearest Reciprocal
The program ROUNDRCP rounds a number to the nearest 1/n. This function can come in handy in several applications, for example, when working with construction or measuring, when have to round results to the nearest eighth (1/8), inch (1/12) or sixteenth (1/16).
Code: EXPORT ROUNDRCP(a,n) Round π to the nearest 1/4: ROUNDRCP(π, 4): 3.25 = 13/4 Round e^2 to the nearest 1/100: ROUNDRCP(e^2, 100): 7.39 = 739/100 Round 1/4 + 2/7 + 3 1/3 to the nearest 1/16: ROUNDRCP(1/4 + 2/7 + 3 + 1/3, 16): 3.875 = 31/8 |
|||
11-28-2017, 05:04 AM
Post: #2
|
|||
|
|||
RE: Rounding to the Nearest Reciprocal
This is exactly the case that fits into user defined functions (when they will remember the variables checkboxes).
PHP Code: IP(A)+SIGN(A)*ROUND(FP(ABS(A))*N,0)/N Otherwise, very nice utility, Eddie! Prime G2, 15C CE |
|||
11-28-2017, 08:30 AM
Post: #3
|
|||
|
|||
RE: Rounding to the Nearest Reciprocal
∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib |
|||
11-30-2017, 01:55 PM
Post: #4
|
|||
|
|||
RE: Rounding to the Nearest Reciprocal
Thank you Chromos and Salvo!
|
|||
12-01-2017, 07:57 AM
(This post was last modified: 12-01-2017 07:58 AM by Dieter.)
Post: #5
|
|||
|
|||
RE: Rounding to the Nearest Reciprocal | |||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)