diff options
author | (no author) <(no author)@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1999-12-07 16:47:21 +0000 |
---|---|---|
committer | (no author) <(no author)@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1999-12-07 16:47:21 +0000 |
commit | b514a325b560d0f36451050e15dd7ff985171d7b (patch) | |
tree | 381b72778e5ed473e47665757e47f66ef7191ce5 /bignum.c | |
parent | be1fea072cd0d22788ef8a931c0c6b64a2503b5d (diff) |
This commit was manufactured by cvs2svn to create tag 'v1_4_3'.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_4_3@582 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bignum.c')
-rw-r--r-- | bignum.c | 17 |
1 files changed, 7 insertions, 10 deletions
@@ -20,7 +20,7 @@ typedef unsigned short USHORT; #define BIGRAD (1L << BITSPERDIG) #define DIGSPERINT ((unsigned int)(sizeof(long)/sizeof(short))) #define BIGUP(x) ((unsigned long)(x) << BITSPERDIG) -#define BIGDN(x) (((x)<0) ? ~((~(x))>>BITSPERDIG) : (x)>>BITSPERDIG) +#define BIGDN(x) RSHIFT(x,BITSPERDIG) #define BIGLO(x) ((USHORT)((x) & (BIGRAD-1))) static VALUE @@ -1255,20 +1255,17 @@ rb_big_abs(x) */ VALUE -rb_big_rand(max) +rb_big_rand(max, rand) VALUE max; + double rand; { - struct RBignum *v; + VALUE v; long len; - len = RBIGNUM(max)->len; - v = RBIGNUM(bignew(len,1)); + len = RBIGNUM(v)->len; + v = bignew(len,1); while (len--) { -#ifdef HAVE_RANDOM - BDIGITS(v)[len] = random(); -#else - BDIGITS(v)[len] = rand(); -#endif + BDIGITS(v)[len] = ((USHORT)~0) * rand; } return rb_big_mod((VALUE)v, max); |