Random number generator

Any way of the forum auto-locking a thread after x years? Or months?

The filter for auto locking zombie threads already exists. Just look at the original post date, and don't read anything older than you want as the filtered time. No programming required. (y)

Bubba.
 
Why locking? For completeness, I'd like to see a translation of that into Rockwell Structured Text

Code:
(*
	RNG calculates random numbers from 0 to 1.
	RNG requires two in_out variables to maintain state.
*)

FUNCTION RNG : REAL
	VAR_IN_OUT
		m_z : DWORD;
		m_w : DWORD;
	END_VAR
	VAR
		u: DINT;
	 END_VAR
	m_z:=DINT_TO_DWORD(36969*DWORD_TO_DINT(m_z AND 16#FFFF)+DWORD_TO_DINT(SHR(m_z,16)));
	m_w:=DINT_TO_DWORD(18000*DWORD_TO_DINT(m_w AND 16#FFFF)+DWORD_TO_DINT(SHR(m_w,16)));
	u :=  DWORD_TO_DINT( SHL(m_z,16))+DWORD_TO_DINT(m_w);
	RNG :=DINT_TO_REAL(u+1)*2.328306435454494E-10+0.5;
END_FUNCTION

// 	http://www.codeproject.com/KB/recipes/SimpleRNG.aspx
I wrote this long ago. Since then the ST specification for converting between types has been loosen up a bit so all the DINT_TO_DWORD and DWORD_TO_DINT are not required.

It would be better if m_z and m_z were part of a function block.
 
Any way of the forum auto-locking a thread after x years? Or months?

I dont have a problem with 'old threads' if someone has something to add to them, xyntec felt they had something to add to the thread and bring up the topic again and now Peter also added to it, so it was good to reopen.

Yes there are some that should not be reopened but this was not one also in a day or two they will be out of sight and out of mind.

If its spam it gets deleted by the mods and as long as no one replies to the thread it goes back in the file and back to the date it was last replied too.
 

Similar Topics

Hey folks, I was just wondering what thoughts were about a completely 100% random number generator. I looked on The Google but didn't really open...
Replies
54
Views
16,436
Hello, Could somebody please help me out with coding a 'Random number generator' in vijeo citect. For example if i create an analog Local...
Replies
3
Views
3,726
Hi,Does anybody know if there are any routines in unity pro that produce random numbers like the routine rand() in C ?
Replies
1
Views
4,021
Ive got a client that needs random numbers generated for a security system. Just want to know if any 1 has some ladder or ST software or scripts...
Replies
11
Views
8,804
Can anyone help me create a few ladder logic lines to randomly generate intergers btw 0-100. I have tryed loading the scan timer value, then ANDD...
Replies
16
Views
13,278
Back
Top Bottom