Lesson #1 - Round to a number at any given place
[1/1] from: gmassar::dreamsoft::com at: 17-Oct-2000 11:36
Later versions of REBOL have a round function as standard.
REBOL fella: Here is my first lesson for those who wish to do an exercise in order to better understand REBOL. Old saying: the more practice, the better programmer. Write a function that performs rounding to a number at any given place. Here are examples.
>> to-round 123.45
>> to-round 123.55
>> to-round -123.45
>> to-round/at 123.344 2
>> to-round 123.345 2
>> to-round/at 12345 -2
>> to-round/at (1.22 // .01) 2
== 1E-2 NOTE: the last one is to answer the earlier message on this list. Send your answer to my email at [gmassar--dreamsoft--com], not to this list. I'll reply with my solution. In a couple of days or so, I'll post the best solution with its author. Have fun! Geo (old professor)