mailing list of musl libc
 help / color / mirror / code / Atom feed
From: "Nadav Har'El" <nyh-RmZWMc9puTNJc61us3aD9laTQe2KTcn/@public.gmane.org>
To: musl-ZwoEplunGu1jrUoiu81ncdBPR1lH4CV8@public.gmane.org
Cc: Osv Dev <osv-dev-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Subject: drand48() gives wrong sequence?
Date: Sun, 21 Sep 2014 14:45:57 +0300	[thread overview]
Message-ID: <CANEVyjv9wwEBibFjqV7XTLzBU2BLvpVPzvxig7ArGceOfpzY7w@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1194 bytes --]

Hi, I ran the following trivial program on both glibc (on Linux), and Musl
(on OSv).

#include <stdio.h>
#include <stdlib.h>

int main() {
        srand48(12345);
        printf("%ld %ld %ld\n", lrand48(), lrand48(), lrand48());
}

Unfortunately, the sequence did not come out the same: On glibc+Linux I got:

     444188209 1973930609 483889296

But on OSv+Musl I got:

     1737082417 264424049 61706384

I expected to get the same sequence because both the drand48(3) man-page on
Linux and the drand48 specification in Posix (
http://pubs.opengroup.org/onlinepubs/9699919799/functions/drand48.html) are
pretty explicit about the formulas that should be used. I also looked at
the Musl code quickly, and it does seem to use these formulas.

Any ideas why I'm getting the wrong sequence?

Thanks,
Nadav.

-- 
Nadav Har'El
nyh-RmZWMc9puTNJc61us3aD9laTQe2KTcn/@public.gmane.org

-- 
You received this message because you are subscribed to the Google Groups "OSv Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to osv-dev+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #2: Type: text/html, Size: 1797 bytes --]

             reply	other threads:[~2014-09-21 11:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-21 11:45 Nadav Har'El [this message]
2014-09-21 12:02 ` Jens Gustedt
     [not found] ` <CANEVyjv9wwEBibFjqV7XTLzBU2BLvpVPzvxig7ArGceOfpzY7w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-09-21 13:27   ` Justin Cormack
2014-09-21 13:45     ` Jens Gustedt
2014-09-21 13:57       ` Jens Gustedt
2014-09-21 14:23         ` Jens Gustedt
2014-09-21 12:20 Nadav Har'El

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=CANEVyjv9wwEBibFjqV7XTLzBU2BLvpVPzvxig7ArGceOfpzY7w@mail.gmail.com \
    --to=nyh-rmzwmc9putnjc61us3ad9latqe2ktcn/@public.gmane.org \
    --cc=musl-ZwoEplunGu1jrUoiu81ncdBPR1lH4CV8@public.gmane.org \
    --cc=osv-dev-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
    /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/musl/

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).