Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
emacs
emacs
Commits
f8b53a82
Commit
f8b53a82
authored
Jul 28, 1994
by
Richard M. Stallman
Browse files
(random): Use rand differently, and distinguish BSD/USG.
parent
8ee9ba64
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
2 deletions
+9
-2
src/sysdep.c
src/sysdep.c
+9
-2
No files found.
src/sysdep.c
View file @
f8b53a82
...
...
@@ -2612,8 +2612,15 @@ random ()
#ifdef HAVE_RAND48
return rand48 ();
#else
/* Arrange to return a range centered on zero. */
return (rand () << 15) + rand () - (1 << 29);
/* The BSD rand returns numbers in the range of 0 to 2e31 - 1,
with unusable least significant bits. The USG rand returns
numbers in the range of 0 to 2e15 - 1, all usable. Let us
build a usable 30 bit number from either. */
#ifdef USG
return (rand () << 15) + rand ();
#else
return (rand () & 0x3fff8000) + (rand () >> 16);
#endif
#endif
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment