<?xml version='1.0' encoding="utf-8"?>
      <rss version='2.0'>
      <channel>
      <title>Форум на Исходниках.RU</title>
      <link>https://forum.sources.ru</link>
      <description>Форум на Исходниках.RU</description>
      <generator>Форум на Исходниках.RU</generator>
  	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=9097&amp;view=findpost&amp;p=89459</guid>
        <pubDate>Mon, 20 Oct 2003 20:10:43 +0000</pubDate>
        <title>randomize();</title>
        <link>https://forum.sources.ru/index.php?showtopic=9097&amp;view=findpost&amp;p=89459</link>
        <description><![CDATA[Visitor: Угу... А я и не думал, что борланд с микрософтом в етом направлении почесаться могут :)))]]></description>
        <author>Visitor</author>
        <category>Алгоритмы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=9097&amp;view=findpost&amp;p=89458</guid>
        <pubDate>Mon, 20 Oct 2003 19:45:53 +0000</pubDate>
        <title>randomize();</title>
        <link>https://forum.sources.ru/index.php?showtopic=9097&amp;view=findpost&amp;p=89458</link>
        <description><![CDATA[albom: <div class='tag-quote'><span class='tag-quote-prefix'>Цитата</span> <span class='tag-quote__quote-info'>Visitor, 20.10.03, 23:31:22</span><div class='quote '>Ну множитель и сдвиг другие, ето понятно...<br>
но почему shr 32? :)<br>
---<br>
тьфу ты... 64 бита.<br>
<br>
Ето в каком? в fpc 64-разр. рандом? Или в tmt?</div></div><br>
Может я чего то и напутал при переводе в паскаль, в оригинале (в файле скомпилированном Делфи6) функция была такой:<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">&nbsp;</div><div class="code_line">; IN:     EAX</div><div class="code_line">; OUT:  EAX</div><div class="code_line">push ebx</div><div class="code_line">xor ebx,ebx</div><div class="code_line">imul edx,[ebx+RandSeed],88405</div><div class="code_line">inc edx</div><div class="code_line">mov [ebx+RandSeed],edx</div><div class="code_line">mul edx</div><div class="code_line">mov eax,edx</div><div class="code_line">pop ebx</div><div class="code_line">ret</div></ol></div></div></div></div><script>preloadCodeButtons('1');</script>]]></description>
        <author>albom</author>
        <category>Алгоритмы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=9097&amp;view=findpost&amp;p=89457</guid>
        <pubDate>Mon, 20 Oct 2003 19:36:18 +0000</pubDate>
        <title>randomize();</title>
        <link>https://forum.sources.ru/index.php?showtopic=9097&amp;view=findpost&amp;p=89457</link>
        <description><![CDATA[dimedrol: Takoi generat bul v pervuh rersiyah stl ():<br>class Randint<br>{<br> &nbsp; &nbsp; &nbsp;unsigned long randx;//Ravnomernoe raspredelenie [0,max] <br>public:<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Randint(long s=0){randx=s;}<br> &nbsp; &nbsp; &nbsp;void &nbsp; &nbsp; &nbsp;seed(long s){randx=s;} <br><br> &nbsp; &nbsp; &nbsp;//privedennue magi4eskie 4isla nujnu dlya <br> &nbsp; &nbsp; &nbsp;//vudeleniya 31 bita iz 32-bitnogo long<br> &nbsp; &nbsp; &nbsp;long abs(long x){return x&0x7fffffff;}<br> &nbsp; &nbsp; &nbsp;static double max(){return 2147483648.0;}<br> &nbsp; &nbsp; &nbsp;long draw(){return randx=randx*1103515245+12345;}<br> &nbsp; &nbsp; &nbsp;double fdraw(){return abs(draw()/max());}<br> &nbsp; &nbsp; &nbsp;long operator(){return abs(draw());}<br>};<br>Vo vsyakom tak stait v Straustrup'e(3-e izdanie).]]></description>
        <author>dimedrol</author>
        <category>Алгоритмы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=9097&amp;view=findpost&amp;p=89456</guid>
        <pubDate>Mon, 20 Oct 2003 19:31:22 +0000</pubDate>
        <title>randomize();</title>
        <link>https://forum.sources.ru/index.php?showtopic=9097&amp;view=findpost&amp;p=89456</link>
        <description><![CDATA[Visitor: Ну множитель и сдвиг другие, ето понятно...<br>но почему shr 32? :)<br>---<br>тьфу ты... 64 бита.<br><br>Ето в каком? в fpc 64-разр. рандом? Или в tmt?]]></description>
        <author>Visitor</author>
        <category>Алгоритмы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=9097&amp;view=findpost&amp;p=89455</guid>
        <pubDate>Mon, 20 Oct 2003 19:28:09 +0000</pubDate>
        <title>randomize();</title>
        <link>https://forum.sources.ru/index.php?showtopic=9097&amp;view=findpost&amp;p=89455</link>
        <description><![CDATA[albom: Сейчас посмотрел в отладчике, как работает стандартная функция Random, получил примерно такой код:<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">function iRandom(A:LongInt):LongWord;</div><div class="code_line">&nbsp;var i:LongWord;</div><div class="code_line">&nbsp;&nbsp; &nbsp; j:Int64;</div><div class="code_line">&nbsp;begin</div><div class="code_line">&nbsp;i:=RandSeed*88405+1;</div><div class="code_line">&nbsp;RandSeed:=i;</div><div class="code_line">&nbsp;j:=Int64(i)*A;</div><div class="code_line">&nbsp;iRandom:=j shr 32;</div><div class="code_line">&nbsp;end;</div></ol></div></div></div></div>]]></description>
        <author>albom</author>
        <category>Алгоритмы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=9097&amp;view=findpost&amp;p=89454</guid>
        <pubDate>Mon, 20 Oct 2003 19:25:04 +0000</pubDate>
        <title>randomize();</title>
        <link>https://forum.sources.ru/index.php?showtopic=9097&amp;view=findpost&amp;p=89454</link>
        <description><![CDATA[Visitor: _randseed := _randseed * 214013 + 2531011 mod 2<sup class='tag-sup'>32</sup><br>random := _randseed div 2<sup class='tag-sup'>16</sup><br>вернуть random<br><br>деление нужно для того, чтобы уменьшить предсказуемость младших битов random]]></description>
        <author>Visitor</author>
        <category>Алгоритмы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=9097&amp;view=findpost&amp;p=89453</guid>
        <pubDate>Mon, 20 Oct 2003 19:15:54 +0000</pubDate>
        <title>randomize();</title>
        <link>https://forum.sources.ru/index.php?showtopic=9097&amp;view=findpost&amp;p=89453</link>
        <description><![CDATA[albom: Функция Randomize просто устанавливает начальное значение для веременной RandSeed. Вот как она описана в Делфи 6:<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">procedure &nbsp; &nbsp; &nbsp; Randomize;</div><div class="code_line">{$IFDEF LINUX}</div><div class="code_line">begin</div><div class="code_line">&nbsp;&nbsp;RandSeed := _time(nil);</div><div class="code_line">{$ENDIF}</div><div class="code_line">{$IFDEF MSWINDOWS}</div><div class="code_line">var</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;systemTime :</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;record</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;wYear &nbsp; : Word;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;wMonth &nbsp;: Word;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;wDayOfWeek &nbsp; &nbsp; &nbsp;: Word;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;wDay &nbsp; &nbsp;: Word;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;wHour &nbsp; : Word;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;wMinute : Word;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;wSecond : Word;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;wMilliSeconds: Word;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;reserved &nbsp; &nbsp; &nbsp; &nbsp;: array [0..7] of char;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;end;</div><div class="code_line">asm</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;LEA &nbsp; &nbsp; EAX,systemTime</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;PUSH &nbsp; &nbsp;EAX</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;CALL &nbsp; &nbsp;GetSystemTime</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;MOVZX &nbsp; EAX,systemTime.wHour</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;IMUL &nbsp; &nbsp;EAX,60</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;ADD &nbsp; &nbsp; AX,systemTime.wMinute &nbsp; { sum = hours * 60 + minutes &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;IMUL &nbsp; &nbsp;EAX,60</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;XOR &nbsp; &nbsp; EDX,EDX</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;MOV &nbsp; &nbsp; DX,systemTime.wSecond</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;ADD &nbsp; &nbsp; EAX,EDX &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { sum = sum * 60 + seconds &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;IMUL &nbsp; &nbsp;EAX,1000</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;MOV &nbsp; &nbsp; DX,systemTime.wMilliSeconds</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;ADD &nbsp; &nbsp; EAX,EDX &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { sum = sum * 1000 + milliseconds &nbsp; &nbsp; &nbsp; }</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;MOV &nbsp; &nbsp; RandSeed,EAX</div><div class="code_line">{$ENDIF}</div><div class="code_line">end;</div></ol></div></div></div></div>Как реализована функция Random не знаю. Но она точно берет значение из RandSeed, делает над ним какое-то преобразование и записывает обратно новое значение этой переменной.]]></description>
        <author>albom</author>
        <category>Алгоритмы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=9097&amp;view=findpost&amp;p=89452</guid>
        <pubDate>Mon, 20 Oct 2003 18:59:10 +0000</pubDate>
        <title>randomize();</title>
        <link>https://forum.sources.ru/index.php?showtopic=9097&amp;view=findpost&amp;p=89452</link>
        <description><![CDATA[Member_3696: Привет Люди :).Не подскажите что представляет из себя функция randomize() и random()<br>то биш по какому алгоритму генерируются случайные числа??]]></description>
        <author>Member_3696</author>
        <category>Алгоритмы</category>
      </item>
	
      </channel>
      </rss>
	