unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#9103: 23.3.50; random* from cl does not support the whole range of integers
@ 2011-07-17  4:03 Leo
  2011-07-18 21:56 ` Glenn Morris
  2020-11-19  5:19 ` Stefan Kangas
  0 siblings, 2 replies; 9+ messages in thread
From: Leo @ 2011-07-17  4:03 UTC (permalink / raw)
  To: 9103

As far as I can see, (random* most-positive-fixnum) only returns a 32bit
integer on 64bit Emacs. This might be an oversight given the age of
cl.el.

Leo





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#9103: 23.3.50; random* from cl does not support the whole range of integers
  2011-07-17  4:03 bug#9103: 23.3.50; random* from cl does not support the whole range of integers Leo
@ 2011-07-18 21:56 ` Glenn Morris
  2011-07-18 21:58   ` Glenn Morris
  2020-11-19  5:19 ` Stefan Kangas
  1 sibling, 1 reply; 9+ messages in thread
From: Glenn Morris @ 2011-07-18 21:56 UTC (permalink / raw)
  To: Leo; +Cc: 9103

Leo wrote:

> As far as I can see, (random* most-positive-fixnum) only returns a 32bit
> integer on 64bit Emacs.

Why does random* even need to exist? What can it do that plain random
cannot?





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#9103: 23.3.50; random* from cl does not support the whole range of integers
  2011-07-18 21:56 ` Glenn Morris
@ 2011-07-18 21:58   ` Glenn Morris
  2011-07-19  1:21     ` Leo
  2011-09-11  3:20     ` Lars Magne Ingebrigtsen
  0 siblings, 2 replies; 9+ messages in thread
From: Glenn Morris @ 2011-07-18 21:58 UTC (permalink / raw)
  To: Leo; +Cc: 9103

Glenn Morris wrote:

> Why does random* even need to exist? What can it do that plain random
> cannot?

...non-integer results, it seems.






^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#9103: 23.3.50; random* from cl does not support the whole range of integers
  2011-07-18 21:58   ` Glenn Morris
@ 2011-07-19  1:21     ` Leo
  2011-07-19  1:28       ` Juanma Barranquero
  2011-09-11  3:20     ` Lars Magne Ingebrigtsen
  1 sibling, 1 reply; 9+ messages in thread
From: Leo @ 2011-07-19  1:21 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 9103

On 2011-07-19 05:58 +0800, Glenn Morris wrote:
> Glenn Morris wrote:
>
>> Why does random* even need to exist? What can it do that plain random
>> cannot?
>
> ...non-integer results, it seems.

We need to extend plain random to support random-states. I plan to do it
once the random module in gnulib is usable.

Another option is to use Mersenne Twister PRNG, which I have in my local
tree (patch: http://paste.pocoo.org/show/ZYhLUPeXlkj405100KX4/). The
files mt19937.[ch] are from its authors'. Do you know if that can be
included in Emacs?

Leo





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#9103: 23.3.50; random* from cl does not support the whole range of integers
  2011-07-19  1:21     ` Leo
@ 2011-07-19  1:28       ` Juanma Barranquero
  0 siblings, 0 replies; 9+ messages in thread
From: Juanma Barranquero @ 2011-07-19  1:28 UTC (permalink / raw)
  To: Leo; +Cc: 9103

On Tue, Jul 19, 2011 at 03:21, Leo <sdl.web@gmail.com> wrote:

> The
> files mt19937.[ch] are from its authors'. Do you know if that can be
> included in Emacs?

From http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/elicense.html :

"Until 2001/4/6, MT had been distributed under GNU Public License, but
after 2001/4/6, we decided to let MT be used for any purpose,
including commercial use. 2002-versions mt19937ar.c, mt19937ar-cok.c
are considered to be usable freely."

    Juanma





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#9103: 23.3.50; random* from cl does not support the whole range of integers
  2011-07-18 21:58   ` Glenn Morris
  2011-07-19  1:21     ` Leo
@ 2011-09-11  3:20     ` Lars Magne Ingebrigtsen
  2011-09-11  7:44       ` Andreas Schwab
  2021-10-22 15:58       ` Stefan Kangas
  1 sibling, 2 replies; 9+ messages in thread
From: Lars Magne Ingebrigtsen @ 2011-09-11  3:20 UTC (permalink / raw)
  To: Glenn Morris; +Cc: Leo, 9103

Glenn Morris <rgm@gnu.org> writes:

> Glenn Morris wrote:
>
>> Why does random* even need to exist? What can it do that plain random
>> cannot?
>
> ...non-integer results, it seems.

`random*' ends with

(* (/ n '8388608e0) lim)

if LIM isn't an integer.  Anybody willing to hazard a guess why
8388608.0 was chosen?

And would it make sense to just replace it all with a call to `random',
and then make it into a floating point if it floats?

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#9103: 23.3.50; random* from cl does not support the whole range of integers
  2011-09-11  3:20     ` Lars Magne Ingebrigtsen
@ 2011-09-11  7:44       ` Andreas Schwab
  2021-10-22 15:58       ` Stefan Kangas
  1 sibling, 0 replies; 9+ messages in thread
From: Andreas Schwab @ 2011-09-11  7:44 UTC (permalink / raw)
  To: Lars Magne Ingebrigtsen; +Cc: Leo, 9103

Lars Magne Ingebrigtsen <larsi@gnus.org> writes:

> `random*' ends with
>
> (* (/ n '8388608e0) lim)
>
> if LIM isn't an integer.  Anybody willing to hazard a guess why
> 8388608.0 was chosen?

Because that's the range of n.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#9103: 23.3.50; random* from cl does not support the whole range of integers
  2011-07-17  4:03 bug#9103: 23.3.50; random* from cl does not support the whole range of integers Leo
  2011-07-18 21:56 ` Glenn Morris
@ 2020-11-19  5:19 ` Stefan Kangas
  1 sibling, 0 replies; 9+ messages in thread
From: Stefan Kangas @ 2020-11-19  5:19 UTC (permalink / raw)
  To: Leo; +Cc: 9103

Leo <sdl.web@gmail.com> writes:

> As far as I can see, (random* most-positive-fixnum) only returns a 32bit
> integer on 64bit Emacs. This might be an oversight given the age of
> cl.el.

This seems to be an issue also with cl-random on current master, AFAICT.





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#9103: 23.3.50; random* from cl does not support the whole range of integers
  2011-09-11  3:20     ` Lars Magne Ingebrigtsen
  2011-09-11  7:44       ` Andreas Schwab
@ 2021-10-22 15:58       ` Stefan Kangas
  1 sibling, 0 replies; 9+ messages in thread
From: Stefan Kangas @ 2021-10-22 15:58 UTC (permalink / raw)
  To: Lars Magne Ingebrigtsen; +Cc: Glenn Morris, Leo, 9103

Lars Magne Ingebrigtsen <larsi@gnus.org> writes:

>> Glenn Morris wrote:
>>
>>> Why does random* even need to exist? What can it do that plain random
>>> cannot?
>>
>> ...non-integer results, it seems.

(That's `cl-random' these days.)

> and then make it into a floating point if it floats?

The Common Lisp version of `random' supports float and integer values
depending on what type its argument has.  I guess that's what
`cl-random' is based on.

I'm not sure if we can change `random' to do the same.  But if there is
a need for random floating point numbers, it does seem unfortunate that
we only have that functionality in CL-Lib.





^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-10-22 15:58 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-17  4:03 bug#9103: 23.3.50; random* from cl does not support the whole range of integers Leo
2011-07-18 21:56 ` Glenn Morris
2011-07-18 21:58   ` Glenn Morris
2011-07-19  1:21     ` Leo
2011-07-19  1:28       ` Juanma Barranquero
2011-09-11  3:20     ` Lars Magne Ingebrigtsen
2011-09-11  7:44       ` Andreas Schwab
2021-10-22 15:58       ` Stefan Kangas
2020-11-19  5:19 ` Stefan Kangas

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).