Computer Science Canada Rounding |
Author: | MihaiG [ Thu Jan 06, 2005 6:36 pm ] |
Post subject: | Rounding |
is ther any way to make a prcedure that rounds a number to the nearcest digit?? |
Author: | Cervantes [ Thu Jan 06, 2005 6:47 pm ] |
Post subject: | |
To the nearest digit? Umm... round(r : real) : int |
Author: | xHoly-Divinity [ Thu Jan 06, 2005 7:01 pm ] |
Post subject: | |
use :1:n e.g. put 53.423:1:2 <-- that will round to 2 decimal places put 53.424:1:3 <-- that will round to 3 decimal places etc. etc. etc. |
Author: | Cervantes [ Thu Jan 06, 2005 7:08 pm ] |
Post subject: | |
That will work if you want to just put the rounded number on the screen in standard text. But, what if you want to round the number and store it as a variable? |
Author: | Martin [ Thu Jan 06, 2005 7:30 pm ] | ||
Post subject: | |||
|
Author: | Genesis [ Tue Feb 15, 2005 1:48 am ] | ||
Post subject: | |||
That doesn't work for me. I changed it to this:
(Changed "Return" to "Result" and removed a bracket.) |
Author: | Delos [ Tue Feb 15, 2005 10:43 am ] |
Post subject: | |
Or you could use the floor() or ceil() commands. |
Author: | Drakain Zeil [ Tue Feb 15, 2005 5:00 pm ] |
Post subject: | |
For rounding up or down anyway. |