Hi Petr, you wrote:

> Hi,
>
> I haven't find easily way to do following:
>
> ->> num: 0.00181716
> == 1.81716E-3
> ->> num
> == 1.81716E-3
> ->> ble: form num
> == "1.81716E-3"

I submitted a script called %format.r to rebol.org that does that.

>> num: 0.00181716
== 1.81716E-3
>> format num
== "0.00"
>> format num 8
== "0.00181716"
>> format num 5
== "0.00182"
>> format num 4 12
== "      0.0018"
>> format num 4 -12
== "0.0018      "

I wrote it without the benefit of the recent discussion on rounding numbers,
so I'd probably do it differently now.

FORMAT has optional arguments, so if you use it in a program you have to be
careful to use all three arguments, or use it at the end of a block or paren.

%format.r also has includes a few other handy things like QT:

>> qt system
self      version   build     product   words     options   user
script    console   ports     network   schemes   error     standard
>> dore random        ; %random.r not posted yet - %dore.r has been posted
Script: "Various kinds of random numbers" (none)
>> qt integer-rand 100 50
46  14  50  27  40  43  16  26  26  18   1   4   8  27  15  28  19  31  38
22  43  30  13  44   2  50  25  24  32  41  36   7  50  37   3  44  43  40
29  15  45  14  33  24  48  46  33  17  36  18  38  39  46   7  25   3  14
28  24  41  27  23  24  24  37  15  11  28  34  41  26  16  40  10  10  11
22  16   7  16  49  14  19  31   5  37   8  14   6  39  25   1  15  24  15
41  49  32  26  29
>> qt normal-rand 30
 0.6822  -0.9408  -0.1845   0.3104   1.4689   0.4905   0.4024  -0.0037
-0.1700  -0.2349   0.3482  -0.0476  -1.3865  -0.5993   0.6304  -0.2174
 0.6070   1.5734  -0.1016  -0.5313  -0.9314   0.2909  -0.4497   1.1222
 1.3270  -0.0707  -0.0237   0.7480  -0.3458  -0.0153

I've made a few un-posted modifications, so if you find it of any use I could
re-post it. I'd be especially grateful if you'd suggest any ways to make it
easier to use.

Eric

Reply via email to