User Tools

Site Tools





Sidebar

prg:64003

Back to PRG index...

Topic: 64003 - All Purpose Rounder

Here's a handy mathmatical formula for rounding numbers to the number of decimal places specified in the variable DP:

10 def fn rd(x)=int(x*10^dp+.5)/10^dp

(note: replace the carat symbols above with the up arrow on the Commodore keyboard)

An example below will round the square root of 5 to 2 decimal places:

20 dp=2
30 print fn rd(sqr(5))
prg/64003.txt · Last modified: 2022/04/27 21:22 by David