Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Lesson #1 - Round to a number at any given place

From: gmassar::dreamsoft::com at: 17-Oct-2000 11:36

Librarian comment

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
== 123
>> to-round 123.55
== 124
>> to-round -123.45
== -123
>> to-round/at 123.344 2
== 123.34
>> to-round 123.345 2
== 123.35
>> to-round/at 12345 -2
== 12300
>> 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)