zsh-workers
 help / color / mirror / code / Atom feed
From: "Peter A. Castro" <doctor@fruitbat.org>
To: zsh-workers@sunsite.dk
Subject: erand48 in mathfunc.c
Date: Thu, 3 Aug 2006 19:26:22 -0700 (PDT)	[thread overview]
Message-ID: <Pine.LNX.4.63.0608031913480.29840@gremlin.fruitbat.org> (raw)

Greetings,
   I've finally had time to look into a problem under Cygwin concerning
the mathfunc module and rand48().  Up until now, these never worked under
Cygwin.  erand48() would always return "0.0" for the value, no matter
what seedbufptr contained, and thus Test/V03mathfunc.ztst would always
fail.
   It seems that some implementations of rand48() need the seed to be
initialized (ie: use seed48(s) before erand48(s)).  Or at least, the
implementation in newlib does.  In anycase, calling seed48(s) solves the
problem and allows erand48() to return real values.  I don't see the harm
in always calling it for seed initialization, so I've not ifdef'ed it.
   It would be interesting to know if other platforms either need this
initializion as well, or produce incorrect results if used.
   In anycase, see patch.  This is against 4.3.2.  I've not checked CVS
lately.

*** 4.3.2/zsh-4.3.2/Src/Modules/mathfunc.c	Tue Nov  1 02:20:24 2005
--- 4.3.2d/zsh-4.3.2/Src/Modules/mathfunc.c	Wed Aug  2 09:53:40 2006
***************
*** 534,539 ****
--- 534,541 ----
   		seedbufptr[0] = (unsigned short)rand();
   		seedbufptr[1] = (unsigned short)rand();
   		seedbufptr[2] = (unsigned short)rand();
+		/* some implementations of rand48 need initialization */
+		seed48(seedbufptr);
   	    }
   	    ret.type = MN_FLOAT;
   	    ret.u.d = erand48(seedbufptr);


-- 
Peter A. Castro <doctor@fruitbat.org> or <Peter.Castro@oracle.com>
 	"Cats are just autistic Dogs" -- Dr. Tony Attwood


                 reply	other threads:[~2006-08-04  2:27 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.63.0608031913480.29840@gremlin.fruitbat.org \
    --to=doctor@fruitbat.org \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

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 NNTP newsgroup(s).