Re: [Chicken-users] u8vector to numbers bignum

2015-05-29 Thread Peter Bex
On Thu, May 28, 2015 at 08:18:14PM -0700, chi wrote: Also, a number-u8vector function would be nice. Converting a number to a hex string, then taking every 2 characters of that and converting that back to a number, for each element of the u8vector, just to keep me from accessing the number's

Re: [Chicken-users] u8vector to numbers bignum

2015-05-29 Thread cowan
chi scripsit: Ironically, that is exactly what the SRFI-27 module implements. http://wiki.call-cc.org/eggref/4/srfi-27#random-sources Could make an insecure random source, or even a totally non-random random source I imagine. I had no idea it was so comprehensively extended. -- John Cowan

Re: [Chicken-users] u8vector to numbers bignum

2015-05-29 Thread Stephen Eilert
On Thu, May 28, 2015 at 9:09 PM, John Cowan co...@mercury.ccil.org wrote: Peter Bex scripsit: If this is such an important feature it may make more sense to include a proper PRNG. Different applications will want fast crude random-ish numbers, PRNGs, cryptographic PRNGs, or full quantum

Re: [Chicken-users] u8vector to numbers bignum

2015-05-29 Thread chi
(define (bignum-u8vector/host-byte-order num) (unless (bignum? num) (error Argument is not a bignum! num)) (let* ((word-size (cond-expand (64bit 8) (else 4))) ; Is there a better way? (bignum-contents (##sys#slot num 1)) ; Digits preceded by sign word (bignum-digits

Re: [Chicken-users] u8vector to numbers bignum

2015-05-28 Thread Michele La Monaca
On Thu, May 28, 2015 at 8:59 AM, Peter Bex pe...@more-magic.net wrote: Yeah, the numbers random implementation is shitty, which is why I decided to omit it from my port to CHICKEN core (CHICKEN 5's random is still fixnum only). Personally, I think it would be better if we simply got rid of

Re: [Chicken-users] u8vector to numbers bignum

2015-05-28 Thread Peter Bex
On Thu, May 28, 2015 at 10:34:55PM +0200, Michele La Monaca wrote: On Thu, May 28, 2015 at 8:59 AM, Peter Bex pe...@more-magic.net wrote: Yeah, the numbers random implementation is shitty, which is why I decided to omit it from my port to CHICKEN core (CHICKEN 5's random is still fixnum

Re: [Chicken-users] u8vector to numbers bignum

2015-05-28 Thread Michele La Monaca
On Thu, May 28, 2015 at 11:23 PM, Peter Bex pe...@more-magic.net wrote: On Thu, May 28, 2015 at 10:34:55PM +0200, Michele La Monaca wrote: On Thu, May 28, 2015 at 8:59 AM, Peter Bex pe...@more-magic.net wrote: Yeah, the numbers random implementation is shitty, which is why I decided to omit

Re: [Chicken-users] u8vector to numbers bignum

2015-05-28 Thread Kon Lovett
On May 27, 2015, at 3:53 PM, chi chic...@verge.info.tm wrote: How would I convert a u8vector to a bignum? I'd like a good large random number, and there's srfi 27 for decent random sources, and there's 'numbers' for bignum support, but srfi-27 only produces fixnums or u8vectors. The

Re: [Chicken-users] u8vector to numbers bignum

2015-05-28 Thread Alex Shinn
On Thu, May 28, 2015 at 3:59 PM, Peter Bex pe...@more-magic.net wrote: Yeah, the numbers random implementation is shitty, which is why I decided to omit it from my port to CHICKEN core (CHICKEN 5's random is still fixnum only). This is surprisingly hard to do well - the Chibi SRFI-27

Re: [Chicken-users] u8vector to numbers bignum

2015-05-28 Thread chi
On 05/28/2015 05:09 PM, John Cowan wrote: Different applications will want fast crude random-ish numbers, PRNGs, cryptographic PRNGs, or full quantum randomness, with tradeoffs for speed and quality. Ironically, that is exactly what the SRFI-27 module implements.

Re: [Chicken-users] u8vector to numbers bignum

2015-05-28 Thread chi
On 05/28/2015 12:55 PM, Kon Lovett wrote: The integer result range extends to that of the limit parameter. Ex: Yeah sorry, I didn't see that the first time, my bad. (random-integer large-bignum) would produce a large bignum just fine. Problem solved! But did you take a look at the

Re: [Chicken-users] u8vector to numbers bignum

2015-05-28 Thread chi
Also, a number-u8vector function would be nice. Converting a number to a hex string, then taking every 2 characters of that and converting that back to a number, for each element of the u8vector, just to keep me from accessing the number's bytes directly, just strikes me as terribly roundabout.

Re: [Chicken-users] u8vector to numbers bignum

2015-05-28 Thread John Cowan
Peter Bex scripsit: If this is such an important feature it may make more sense to include a proper PRNG. Different applications will want fast crude random-ish numbers, PRNGs, cryptographic PRNGs, or full quantum randomness, with tradeoffs for speed and quality. Since that's so, I'd rather

Re: [Chicken-users] u8vector to numbers bignum

2015-05-28 Thread Peter Bex
On Wed, May 27, 2015 at 03:53:39PM -0700, chi wrote: How would I convert a u8vector to a bignum? I'd like a good large random number, and there's srfi 27 for decent random sources, and there's 'numbers' for bignum support, but srfi-27 only produces fixnums or u8vectors. I don't know

Re: [Chicken-users] u8vector to numbers bignum

2015-05-28 Thread cowan
Personally, I think it would be better if we simply got rid of all random support in core, because there's no way this is ever going to satisfy everyone. Besides, the standard C library functions are deeply flawed, especially on some platforms like OS X. Emphatic +1. -- John Cowan

[Chicken-users] u8vector to numbers bignum

2015-05-27 Thread chi
How would I convert a u8vector to a bignum? I'd like a good large random number, and there's srfi 27 for decent random sources, and there's 'numbers' for bignum support, but srfi-27 only produces fixnums or u8vectors. Logically I can't imagine a bignum isn't represented under the hood by a block