nrand48?!?!?!?! [英] nrand48 ?!?!?!?!

查看:177
本文介绍了nrand48?!?!?!?!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始明白为什么微软不包括这个nrand SHIT !!!!


1.文档是SHIT


2.实施是SHIT


= D


其他单词UNIX就是这样!


。如果THESE他妈的白痴甚至不能做一个他妈的随机函数和

原稿它做好,让人们可以把它理解


那会是什么这些愚蠢的UNIX FUCKHEADS DO对了????


大声笑,谢谢:D


我会留下我写的那些平静的帖子在这个咆哮之前LOL


虽然我认为RANT更重要;)


好​​的,


我现在完全失去了;)


3不同的结果实际上是4 ...而且文档没有帮助。


1.在linux / knoppix上的不同结果

2.在windows xp上的不同结果

2.1使用括号时的不同结果

2.2不同结果如果state48被更改/初始化???


如何使用nrand48(??? )???????????


带一些参数???


文档不清楚这个或功能不正常

;)


我认为文件说nrand48可以在没有初始化的情况下使用

任何东西? ??


"

erand48(),nrand48()和jrand48()函数不需要

初始化入口点首先被调用。

"


???


int main()

{

uint16 state48 [3];


// state48 [0] = 0;

// state48 [1] = 0;

// state48 [2] = 0;

printf("%d \ n",nrand48(state48)) ;

printf("%d \ n",nrand48(state48));

printf("%d \ n",nrand48(state48)) ;

printf("%d \ n",nrand48(state48));

printf("%d \ n",nrand48(state48)) ;


// windows xp / vis ual c / c ++ 6.0输出为:

//源版本0.01 - 版本0.03:

//无括号:


// 1288336289

// 893806678

// 810173679

// 37620279

// 474250687

//源版本0.04:

//带括号:


// 257717153

// 323532094

// 23385569

// 378241935

// 2040867715


/ / linux / knoppix 3.1 kdev ???输出为:

//源版本0.03:


//默认nrand48:

// 1367402799

// 1703755632

// 1875357054

// 1202986045

// 1604074163


返回0;

}


叹气,

如果nrand48和测试程序产生相同的结果会很好<


1. Linux / Knoppix

2. Windows XP


Isn它应该产生相同的输出吗?


如果是,


然后可能测试程序有缺陷

然后可能nrand48例程有缺陷


如果没有


然后完全使用unix shit并继续前进= D替换它/使用它... 。


NONONO不能这样做...


我需要一个好的nrand48()函数来确保程序的运行方式它是

设计的。


虽然看到编码器不使用((()))使计算更多

强大的开始让我对编码器的质量水平感到疑惑。


如果我设计了一种编程语言,我会确定这段代码

永远无法编译;)


a = f<< b | c>> d * e / k; //或任何其他类似的代码;)


只允许这样:


a =((f<< b) |(c>> d)* e)/ k; //或者它的任何方式

只要2个操作数很好地包装在()中就可以进行计算;)


所有数学人都可以去一棵树:)


正如你所看到的那样,我已经厌倦了nrand48,C,C

程序员以及这里面和外面的热情fricking

公寓:d


。在这一点上我他妈的失去了它,并取得了他妈的RANT LOL

YESSSSSSSsssssssssssssssssssssssssssssssssssssssss sssssssssssss


再见,

Skybuck

I am beginning to see why microsoft did not include this nrand SHIT !!!!

1. The documentation is SHIT

2. The implementation is SHIT

=D

IN OTHER WORDS UNIX IS SHIT !

IF THESE FUCKING IDIOTS CANT EVEN MAKE A FUCKING RANDOM FUNCTION AND
DOCUMENT IT WELL SO THAT PEOPLE CAN UNDERSTAND IT

THEN WHAT CAN THESE STUPID UNIX FUCKHEADS DO RIGHT ????

Lol, Thank you :D

I''ll leave the rest of my calm post in which I wrote before this rant LOL

Though I think the RANT is more important ;)

Ok,

I am at a total loss now ;)

3 Different results actually 4... and the documentation ain''t helping.

1. Different results on linux/knoppix
2. Different results on windows xp
2.1 Different results when using brackets
2.2 Different results if state48 is changed/initialized ???

How is one supposed to use nrand48( ??? ) ?????????????

With some parameters ???

The documentation is not clear about this or the function is mal functioning
;)

I think the documentation says nrand48 can be used without initialising
anything ???

"
The erand48(), nrand48() and jrand48() functions do not require an
initialisation entry point to be called first.
"

???

int main()
{
uint16 state48[3];

//state48[0] = 0;
//state48[1] = 0;
//state48[2] = 0;
printf("%d \n", nrand48(state48) );
printf("%d \n", nrand48(state48) );
printf("%d \n", nrand48(state48) );
printf("%d \n", nrand48(state48) );
printf("%d \n", nrand48(state48) );

// the windows xp / visual c/c++ 6.0 output is:
// source version 0.01 - version 0.03:
// without brackets:

// 1288336289
// 893806678
// 810173679
// 37620279
// 474250687

// source version 0.04:
// with brackets:

// 257717153
// 323532094
// 23385569
// 378241935
// 2040867715

// the linux/knoppix 3.1 kdev ??? output is:
// source version 0.03:

// default nrand48:
// 1367402799
// 1703755632
// 1875357054
// 1202986045
// 1604074163

return 0;
}

Sigh,
It would be nice if nrand48 and the test program produced the same results
on

1. Linux/Knoppix
2. Windows XP

Isn''t it supposed to produce the same output ?

If Yes,

Then possibly test program flawed
Then possibly nrand48 routine flawed

If no

Then quite with unix shit and move on =D replace it/use it whatever...

NONONO can''t do that...

I need a good nrand48() function to make sure the program works like it was
designed.

Though seeing a coder not using ( ( ( ) ) ) to make the calculations more
robust starts to make me wonder about the coder''s quality level.

If I ever design a programming language I''ll make damn sure that this code
can''t compile ever ;)

a = f << b | c >> d * e / k; // or any other code like it ;)

Only this will be allowed:

a = ( ( f << b ) | ( c >> d ) * e ) / k; // or whatever way it was ment to
do the calculations as long as 2 operands are nicely wrapped in () ;)

All math people can go up a tree :)

As you can see I am getting pretttttttty fed up with nrand48, C, C
programmers and the fricking heat inside and outside this fricking
appartment :D

At this point I fucking lost it and made the fucking RANT LOL
YESSSSSSSsssssssssssssssssssssssssssssssssssssssss sssssssssssss

Bye,
Skybuck

推荐答案

文章< cc **** ****** @ news5.tilbu1.nb.home.nl>,

Skybuck Flying< no **** @ hotmail.com>写道:
In article <cc**********@news5.tilbu1.nb.home.nl>,
Skybuck Flying <no****@hotmail.com> wrote:
在其他词语UNIX是的!


当你遇到GNU(Gnu

不是Unix)软件,Linux软件和MS Windows软件时,你为什么抱怨UNIX?为什么

怪UNIX?

如何使用nrand48(???)????????????

有一些参数???


是的。一个参数(指向包含48位Xi的数组的指针),nrand48函数可用于在调用之间存储状态数据。如果你需要使用相同的随机序列,每次需要使用已知的Xi来初始化这个

数组时。

我认为文档说nrand48可以在没有初始化的情况下使用
任何东西???


是的,但是你的随机序列取决于最初的Xi。

如果nrand48和测试程序产生相同的结果会很好
on

1. Linux / Knoppix
2. Windows XP


除非你初始化Xi(你调用state48的数组)算法

将以不同的Xi值开始,具体取决于未定义的垃圾是什么

存在于state48中(您已将其设为自动变量,因此它将具有

undefined创建它时的垃圾)。

它不应该产生相同的输出吗?
IN OTHER WORDS UNIX IS SHIT !
Why are you complaining about UNIX when you have trouble with GNU (Gnu
is Not Unix) software, Linux software and MS Windows software? Why
blame UNIX?
How is one supposed to use nrand48( ??? ) ?????????????

With some parameters ???
Yes. One argument (a pointer to an array containing a 48 bit Xi) that
the nrand48 function can use to store state data between calls. If you
need the same random sequence each time you need to initialize this
array with a known Xi.
I think the documentation says nrand48 can be used without initialising
anything ???
Yes, but then your random sequence depends on the initial Xi.
It would be nice if nrand48 and the test program produced the same results
on

1. Linux/Knoppix
2. Windows XP
Unless you initialize Xi (the array you call state48) the algorithm
will start with different Xi values depending on what undefined junk is
present in state48 (you have made it an auto variable so it will have
undefined junk in it when it is created).
Isn''t it supposed to produce the same output ?




与Xi相同应该。它在我的系统上运行,但是我使用了一个真正的

UNIX系统,而不是你似乎使用的那种想要的系统。


如果实现你正在使用不同的内部参数

然后你可以使用lcong48()在调用nrand48()之前更改它们。


-

G?ran Larsson http://www.mitt-eget.com/


Skybuck Flying< no **** @ hotmail.com>写道:
Skybuck Flying <no****@hotmail.com> wrote:
我开始明白为什么微软不包括这个nrand SHIT !!!!


MS可能从未尝试过,因为已经宣布这些功能已经过去了几年,几年和几年。从你发声的方式来看,他们可能已经在你出生前被宣布弃用了。我的

Linux文档明确表示


这些函数被SVID 3宣布为过时的,

表示rand(3)应该相反。


你是唯一坚持使用它的人。

1.文件是SHIT


你读过吗?它不能让你觉得你没有。

你是否已经想出如何使用男人 UNIX下的命令?

2.实现SHIT


不,它完全正常工作。当你试图将它移动到另一个系统而没有正确理解发生了什么时,你只会把它弄得一团糟




<更愚蠢的咆哮>

怎么一个人应该使用nrand48(???)?????????????
有些参数???
文档不清楚这个或功能是否正常运行
;)


正如文档中所述。你用一个数组来调用它来获得3个无符号短整数值的
,其中包含用于在调用之间存储函数的

中间状态的值。

我认为文档说nrand48可以在没有初始化的情况下使用
任何东西???


不,您可以通过设置

数组中3个值的初始值来调用''state48''。

int main()
{
uint16 state48 [3];
// state48 [0] = 0;
// state48 [1] = 0;
// state48 [2] = 0;


这样,state48数组未初始化,在启动程序时保留一些完全

的随机值。这些值甚至可以在程序的每次调用中有不同的机会,

导致每次运行时出现不同的数字序列。


制作


unsigned short int state48 [3] = {0,0,0};


按顺序以明确定义的初始值开始。

printf("%d \ n",nrand48(state48));
printf("%d \ n", nrand48(state48));
的printf(QUOT;%d \\\
" ;, nrand48(state48));
的printf(QUOT;%d \\\
" ;, nrand48(state48)); <无线电通信/> printf("%d \ n",nrand48(state48));


< bogus resultsts snipped>


猜猜看:我的Linux盒子上有(用state8初始化为0)::


0

2116118

89401895

379337186​​

782977366
196130996

和IRIX,即使用不同的架构,不同的操作系统,

a不同的编译器,不同的libc:


0

2116118

89401895

379337186​​

782977366

196130996

和OSF1,即另一个不同的架构,另一个不同的操作系统,

另一个不同的编译器和另一个不同的libc:


0

2116118

89401895

379337186​​

782977366

196130996


所以你看到:函数的三个不同的,独立的实现

并且都给出了相同的结果。对不起,但是因为我只是一个STUPID

UNIX FUCKHEAD。我无法为MS系统提供任何结果...

返回0;
}
如果nrand48和测试程序产生相同的结果,那将是很好的


好​​吧,不是吗?

难道它不应该产生相同的输出吗?
如果是,
然后可能测试程序有缺陷
然后可能nrand48例行有缺陷


可能两者都有。

我需要一个很好的nrand48()函数,以确保程序像
设计的那样工作。


您尝试这样做的方式(即通过从某些实现中复制一些相当神秘的内部

代码,您似乎无法理解而不是

试图理解算法并做一个干净的新实现)

显然会使一切变得不必要地复杂化并导致

几乎无法读取的代码。


看,下面我花了不到10分钟就完成了。

它和使用nrand48()函数的结果完全相同

来自glibc的比较前1000万
电话的结果(这当然不能证明实施是正确的

但似乎足够好对我来说):


#include< stdio.h>

#include< stdlib.h>

static long int n48(unsigned short int xsub [3]);


int main(void)

{

int i;

unsigned s hort xsubi [3] = {0,0,0};


for(i = 0;我< 5; i ++)

printf("%ld \ n",n48(xsubi));

返回EXIT_SUCCESS;

}


static long int n48(unsigned short int xsub [3])

{

static unsigned long long a = 0x5DEECE66DULL;

static unsigned long long c = 0xBULL;

unsigned long long X =((unsigned long long)xsub [2]<< 32)|

((unsigned long long)xsub [1]<< 16)|

(unsigned long long)xsub [0];


X = X * a + c;


xsub [0] = X& 0xFFFF;

xsub [1] =(X>> 16)& 0xFFFF;

xsub [2] =(X>> 32)& 0xFFFF;


返回(X>> 17)& 0x7FFFFFFFUL;

}


您需要做的就是替换unsigned long long和unsigned long long。 uint64的东西

(或其他),因为你的编译器似乎不知道长

长因此你必须使用一些特殊的魔法来获得正确的

类型。但是不要把这归咎于C,这只是我们的编译器要求b $ b quires的东西。您可能还必须删除ULL。在常量之后咬一下

或用编译器理解的东西替换它。

虽然看到编码器没有使用((())来使计算更多
强大的开始使我对编码器的质量水平感到疑惑。
I am beginning to see why microsoft did not include this nrand SHIT !!!!
MS probably never tried to because that functions have been declared
obsolete since years and years and years. From the way you sound they
probably were already declared deprecated before you were born. My
Linux documentation explicitely says

These functions are declared obsolete by SVID 3, which
states that rand(3) should be used instead.

You are the only one insisting on using it.
1. The documentation is SHIT
Have you read it? It can''t keep from getting the feeling that you didn''t.
Have you already figured out how to use the "man" command under UNIX?
2. The implementation is SHIT
No, it works exactly as it should. It''s only you making a mess out
of it when you try to move it to another system without properly
understanding what''s going on.

<more stupid rant snipped>
How is one supposed to use nrand48( ??? ) ????????????? With some parameters ??? The documentation is not clear about this or the function is mal functioning
;)
Exactly as described in the documentation. You call it with an array
of 3 unsigned short int values which contain values for storing the
intermediate state of the function between calls.
I think the documentation says nrand48 can be used without initialising
anything ???
No, you do that by setting initial values for the 3 values in the
array you call ''state48''.
int main()
{
uint16 state48[3]; //state48[0] = 0;
//state48[1] = 0;
//state48[2] = 0;
That way the state48 array is uninitialized, holding some completely
random values when you start the program. The values have even a
good chance to be different on each invocation of the program,
resulting in a different sequence of numbers in each run.

Make that

unsigned short int state48[ 3 ] = { 0, 0, 0 };

in order to start with a well-defined initial value.
printf("%d \n", nrand48(state48) );
printf("%d \n", nrand48(state48) );
printf("%d \n", nrand48(state48) );
printf("%d \n", nrand48(state48) );
printf("%d \n", nrand48(state48) );
<bogus resultts snipped>

Guess what: I get (with state48 initialized with 0) on my Linux box::

0
2116118
89401895
379337186
782977366
196130996

and on IRIX, i.e. using a different architecture, a different OS,
a different compiler, a different libc:

0
2116118
89401895
379337186
782977366
196130996

and on OSF1, i.e. another different architecture, another different OS,
another different compiler and another different libc:

0
2116118
89401895
379337186
782977366
196130996

So you see: three different, independend implementations of the function
and all giving the same results. I''m sorry, but since I''m just a "STUPID
UNIX FUCKHEAD" I can''t deliver any results for an MS system...
return 0;
} It would be nice if nrand48 and the test program produced the same results
Well, wouldn''t it?
Isn''t it supposed to produce the same output ? If Yes, Then possibly test program flawed
Then possibly nrand48 routine flawed
Probably both.
I need a good nrand48() function to make sure the program works like it was
designed.
The way you try to do it (i.e. by copying some rather cryptic internal
code from some implementation you don''t seem to understand instead of
trying to understand the algorithm and doing a clean new implementation)
obviously makes everything unnecessarily complicated and results in
nearly unreadable code.

Look, the following took me less than 10 minutes to put together.
And it gives exactly the same results as using the nrand48() function
coming from the glibc when comparing results for the first ten million
calls (which of course is no proof that the implementation is correct
but seems to be good enough for me at the moment):

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

static long int n48( unsigned short int xsub[ 3 ] );

int main( void )
{
int i;
unsigned short xsubi[ 3 ] = { 0, 0, 0 };

for ( i = 0; i < 5; i++ )
printf( "%ld\n", n48( xsubi ) );
return EXIT_SUCCESS;
}

static long int n48( unsigned short int xsub[ 3 ] )
{
static unsigned long long a = 0x5DEECE66DULL;
static unsigned long long c = 0xBULL;
unsigned long long X = ( ( unsigned long long ) xsub[ 2 ] << 32 ) |
( ( unsigned long long ) xsub[ 1 ] << 16 ) |
( unsigned long long ) xsub[ 0 ];

X = X * a + c;

xsub[ 0 ] = X & 0xFFFF;
xsub[ 1 ] = ( X >> 16 ) & 0xFFFF;
xsub[ 2 ] = ( X >> 32 ) & 0xFFFF;

return ( X >> 17 ) & 0x7FFFFFFFUL;
}

All you need to do is replace the "unsigned long long" stuff by uint64
(or whatever) because your compiler does not seem to know about "long
long" and you thus have to use some special magic to get at the correct
types. But don''t blame this on C, it''s just something our compiler re-
quires. You may also have to remove the "ULL" bit after the constants
or replace it with something your compiler understands.
Though seeing a coder not using ( ( ( ) ) ) to make the calculations more
robust starts to make me wonder about the coder''s quality level.




他们不再进行强大的计算。如果你把一些地方放在他们不需要b $ b的地方你可能只是让代码更容易阅读一个没有经验的程序员。为什么你不至少花时间查阅

一个简单的C运算符优先级表,找出它们的位置
需要
?或者你不明白你想写的代码吗?


问候,Jens

-

\ Jens Thoms Toerring ___ Je *********** @ physik.fu-berlin.de

\ __________________________ http: //www.toerring.de


非常感谢您对这个平静而清晰的解释。


请参阅简单就是这样吗?


与此比较:

http://www.opengroup.org/onlinepubs/...h/drand48.html


然后,任何人阅读我的积极回应都会理解为什么会这样。

汇总:D


从我的角度来看,这是最好的:


我不给AF ** K NRand48如何工作,我Ju st想要能够使用它

= DDDDDD LOL


所有我需要知道的是:


NRand48(一些F *** ED参数)


传递给NRand48的参数用于生成随机值。传递给NRand48的

参数也会更新/更改,以便下次使用修改后的参数调用该函数时,

将被制作并返回。

$ b一样,$ b的东西会就好了,叹了口气。


,而nooooooooooooooooooooooooooooooooooooooooooooooooo OOOOOOO


必须是笨的像荷马·辛普森....必须做出复杂的语句......必须

认为像机器人HAHAHA。


BYEEEEeeeee我甚至不把我的名字置于此之下:P *****
Well Thank You For This Calm And Clear Explanation.

See How Simple That Was ?

Compare That With This:

http://www.opengroup.org/onlinepubs/...h/drand48.html

Then Anybody Reading My Aggreviated Response Will Understand Why It Was
Aggreviated :D

Well At Least When You Look At It From My Perspective:

"I Don''t Give A F**K How NRand48 Works, I Just Want To Be Able To Use It"
=DDDDDD LOL

All I Needed To Know Is:

NRand48( Some F***ED Parameter )

The parameter passed to NRand48 is used to generate the random value. The
parameter passed to NRand48 is also updated/changed so that the next time
the function is called with the modified parameter the next random value
will be produced and returned.

Something like that would be just fine, sigh.

But nooooooooooooooooooooooooooooooooooooooooooooooooo ooooooo

MUST BE STUPID LIKE HOMER SIMPSONS.... MUST MAKE COMPLEX STATEMENTS... MUST
THINK LIKE ROBOT HAHAHA.

BYEEEEeeeee I am not even putting my name under this :P*****


这篇关于nrand48?!?!?!?!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆