����� �� �����.


������ ���������.

����������: ��������� ��������������� �������������������.

����� ������� ��������� ��� 32-�������� ������������� ����� � �������������� �����.

© Nikitine Valeri 2000

����������� �������, ����� ���� unsigned long ����� 32 ����. � ���� ������ ��� ��������� ����� � ��������� 0 - 232-1 ���������� �������� ��������� �� �������������� � �������� � �����������. ������� �� ������ ����� ����������� ������������� ��� ������������. �������� ��������������� � ���������� ��� ����� ������ �������� � ������������� D. Knuth � H.W. Lewis.

/* ��������� ������ ����� �� 0 �� 0xFFFFFFFF. */
static unsigned long iran;
...........
iran=1664525L*iran+1013904223L;

�� ���������� �� ���� ������ ����� �������� ���������� ������������ ������������� �������������� ����� �� 0 �� 1 �����, ��� floating-point single precision numbers (��� float) � ����������� ������� ������������ ����� 32 ������. ����� ����, �� ������ ������� (������� SUN, ALPHA, Silicon Graphics � IBM PC) ������������� ����� ����� �������� ������ ��������� IEEE. ��� ������ VAX ��� �� ���.

������ ������, ����������� ��������� ������� �� �������������� �����, �������� ���������� ���������� � ���������� ��������� �� ����� �������. ����������� ������������ � ��������� ��������� ��� IEEE (�� ���������) � ��� VAX.

static unsigned long iran;
unsigned long temp;
float fran;
..........
#if !defined(VAX)
 static unsigned long jflone=0x3f800000;
 static unsigned long jflmsk=0x007fffff;
#else
 static unsigned long jflone=0x00004080;
 static unsigned long jflmsk=0xffff007f;
#endif
..........
iran=1664525L*iran+1013904223L;
temp=jflone|(jflmsk&iran);
fran=(*(float *)&temp)-1.F;

����� ������ ������������, ������������� ���������� ��������, � �� �������, ���� ��������� �������� '����� �������', ��������� ���������� ������� �� ������������� ����� � ����������. �������, ���� ��������� � ����������� ����������� ������������ ������� �������� �����, � ������� - ����� ������.




����� �� ��������, � ���������� � ���������.

SpyLOG