[前][次][番号順一覧][スレッド一覧]

ruby-changes:19302

From: sorah <ko1@a...>
Date: Mon, 25 Apr 2011 08:25:17 +0900 (JST)
Subject: [ruby-changes:19302] Ruby:r31341 (trunk): * random.c (rb_f_rand, random_s_rand): RDocs for them.

sorah	2011-04-25 08:25:11 +0900 (Mon, 25 Apr 2011)

  New Revision: 31341

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=31341

  Log:
    * random.c (rb_f_rand, random_s_rand): RDocs for them.

  Modified files:
    trunk/ChangeLog
    trunk/random.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 31340)
+++ ChangeLog	(revision 31341)
@@ -1,3 +1,7 @@
+Mon Apr 25 08:24:04 2011  Shota Fukumori  <sorah@t...>
+
+	* random.c (rb_f_rand, random_s_rand): RDocs for them.
+
 Mon Apr 25 07:18:00 2011  Kenta Murata  <mrkn@m...>
 
 	* random.c (random_s_rand, Init_Random): Random.rand should behave as
Index: random.c
===================================================================
--- random.c	(revision 31340)
+++ random.c	(revision 31341)
@@ -1199,15 +1199,23 @@
  *  call-seq:
  *     rand(max=0)    -> number
  *
- *  Converts <i>max</i> to an integer using max1 =
- *  max<code>.to_i.abs</code>. If _max_ is +nil+ the result is zero, returns a
- *  pseudorandom floating point number greater than or equal to 0.0 and
- *  less than 1.0. Otherwise, returns a pseudorandom integer greater
- *  than or equal to zero and less than max1. <code>Kernel::srand</code>
- *  may be used to ensure repeatable sequences of random numbers between
- *  different runs of the program. Ruby currently uses a modified
- *  Mersenne Twister with a period of 2**19937-1.
  *
+ *  If <i>max</i> is +Range+, returns a pseudorandom number where
+ *  range.member(number) == true.
+ *
+ *  Or else converts _max_ to an integer using max1 =
+ *  max<code>.to_i.abs</code>. 
+ *
+ *  Then if _max_ is +nil+ the result is zero, returns a pseudorandom floating
+ *  point number greater than or equal to 0.0 and less than 1.0.
+ *
+ *  Otherwise, returns a pseudorandom integer greater than or equal to zero and
+ *  less than max1.
+ *
+ *  <code>Kernel::srand</code> may be used to ensure repeatable sequences of
+ *  random numbers between different runs of the program. Ruby currently uses
+ *  a modified Mersenne Twister with a period of 2**19937-1.
+ *
  *     srand 1234                 #=> 0
  *     [ rand,  rand ]            #=> [0.191519450163469, 0.49766366626136]
  *     [ rand(10), rand(1000) ]   #=> [6, 817]
@@ -1235,6 +1243,15 @@
     return r;
 }
 
+/*
+ *  call-seq:
+ *     Random.rand -> float
+ *     Random.rand(limit) -> number
+ *
+ *     Alias of _Random::DEFAULT.rand_.
+ *
+ */
+
 static VALUE
 random_s_rand(int argc, VALUE *argv, VALUE obj)
 {

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]