<?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=14377&amp;view=findpost&amp;p=121986</guid>
        <pubDate>Fri, 22 Aug 2003 14:11:52 +0000</pubDate>
        <title>Как взять от вещественного числа его целую часть?</title>
        <link>https://forum.sources.ru/index.php?showtopic=14377&amp;view=findpost&amp;p=121986</link>
        <description><![CDATA[albom:  <!--QuoteBegin--></div><table border=&#39;0&#39; align=&#39;center&#39; width=&#39;95%&#39; cellpadding=&#39;3&#39; cellspacing=&#39;1&#39;><tr><td><b>Цитата</b> </td></tr><tr><td id=&#39;QUOTE&#39;><!--QuoteEBegin-->2 albom: а, случаем, код из сообщения 8 не запорется, если single поменять на double или extended? <!--QuoteEnd--></td></tr></table><div class=&#39;postcolor&#39;><!--QuoteEEnd--><br>Конечно, он работать не будет. Нужно будет заменить константы: 23 на 52, 8 на 11, 127 на 2047, 150 на 2099, а к &#036;80000000 дописать еще 8 нулей (это для Double). <br>Аналогично замена производится для типов Real и Extended. <br><br>2 Mixxx: А зачем тебе нужен &quot;самый софтварный метод&quot;, если не секрет, конечно? ]]></description>
        <author>albom</author>
        <category>Pascal</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=14377&amp;view=findpost&amp;p=121985</guid>
        <pubDate>Fri, 22 Aug 2003 13:30:13 +0000</pubDate>
        <title>Как взять от вещественного числа его целую часть?</title>
        <link>https://forum.sources.ru/index.php?showtopic=14377&amp;view=findpost&amp;p=121985</link>
        <description><![CDATA[tserega: 2 albom: а, случаем, код из сообщения 8 не запорется, если single поменять на double или extended?]]></description>
        <author>tserega</author>
        <category>Pascal</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=14377&amp;view=findpost&amp;p=121984</guid>
        <pubDate>Fri, 22 Aug 2003 13:27:44 +0000</pubDate>
        <title>Как взять от вещественного числа его целую часть?</title>
        <link>https://forum.sources.ru/index.php?showtopic=14377&amp;view=findpost&amp;p=121984</link>
        <description><![CDATA[Mixxx: 2 albom <br>Спасибо, мне понравилось решение из 7-ой мессаги.<br>Самый софтварный метод :)<br>Сам придумал?]]></description>
        <author>Mixxx</author>
        <category>Pascal</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=14377&amp;view=findpost&amp;p=121983</guid>
        <pubDate>Fri, 22 Aug 2003 12:19:45 +0000</pubDate>
        <title>Как взять от вещественного числа его целую часть?</title>
        <link>https://forum.sources.ru/index.php?showtopic=14377&amp;view=findpost&amp;p=121983</link>
        <description><![CDATA[albom: И еще:<br>
<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 power2(s: Integer): Longint;</div><div class="code_line">var r: Longint;</div><div class="code_line">begin</div><div class="code_line">&nbsp;&nbsp; &nbsp;if s &#60; 0 then begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;power2 := 0; exit</div><div class="code_line">&nbsp;&nbsp; &nbsp;end;</div><div class="code_line">&nbsp;&nbsp; &nbsp;r := 1;</div><div class="code_line">&nbsp;&nbsp; &nbsp;while s &#62; 0 do begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;r := r*2;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;dec(s);</div><div class="code_line">&nbsp;&nbsp; &nbsp;end;</div><div class="code_line">&nbsp;&nbsp; &nbsp;power2:=r;</div><div class="code_line">end;</div><div class="code_line">&nbsp;</div><div class="code_line">var</div><div class="code_line">&nbsp;&nbsp; &nbsp;i: longint;</div><div class="code_line">&nbsp;&nbsp; &nbsp;r: single;</div><div class="code_line">&nbsp;&nbsp; &nbsp;e,m: longint;</div><div class="code_line">&nbsp;&nbsp; &nbsp;s: boolean;</div><div class="code_line">begin</div><div class="code_line">&nbsp;&nbsp; &nbsp;r := -123.456;</div><div class="code_line">&nbsp;&nbsp; &nbsp;m := longint(r) and ((1 shl 23) - 1);</div><div class="code_line">&nbsp;&nbsp; &nbsp;e := (longint(r)shr 23) and (1 shl 8 - 1);</div><div class="code_line">&nbsp;&nbsp; &nbsp;s := longint(r) and 000000 &#60;&#62; 0;</div><div class="code_line">&nbsp;&nbsp; &nbsp;if e &#60;&#62; 0 then begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if e - 150 &#60; 0 then i := power2(e - 127) + m div power2(150 - e)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;else i := (power2(e - 127) + m * power2(e - 150));</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if s then i := -i;</div><div class="code_line">&nbsp;&nbsp; &nbsp;end</div><div class="code_line">&nbsp;&nbsp; &nbsp;else i := 0;</div><div class="code_line">&nbsp;&nbsp; &nbsp;writeln(i); { В &quot;i&quot; находится целая часть }</div><div class="code_line">end.</div></ol></div></div></div></div><script>preloadCodeButtons('1');</script>]]></description>
        <author>albom</author>
        <category>Pascal</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=14377&amp;view=findpost&amp;p=121982</guid>
        <pubDate>Fri, 22 Aug 2003 11:49:17 +0000</pubDate>
        <title>Как взять от вещественного числа его целую часть?</title>
        <link>https://forum.sources.ru/index.php?showtopic=14377&amp;view=findpost&amp;p=121982</link>
        <description><![CDATA[albom: А вот еще вариант:<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">var</div><div class="code_line">&nbsp;&nbsp; &nbsp;i: longint;</div><div class="code_line">&nbsp;&nbsp; &nbsp;s: integer;</div><div class="code_line">&nbsp;&nbsp; &nbsp;r: real;</div><div class="code_line">&nbsp;&nbsp; &nbsp;setbit: boolean;</div><div class="code_line">begin</div><div class="code_line">&nbsp;&nbsp; &nbsp;r := 123.4567;</div><div class="code_line">&nbsp;&nbsp; &nbsp;if r &#60; 0 then begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;r := -r; setbit := true;</div><div class="code_line">&nbsp;&nbsp; &nbsp;end</div><div class="code_line">&nbsp;&nbsp; &nbsp;else setbit := false;</div><div class="code_line">&nbsp;&nbsp; &nbsp;i := 0;</div><div class="code_line">&nbsp;&nbsp; &nbsp;for s := 30 downto 0 do begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;i := i or (word(1) shl s);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if i &#62; r then i := i and not(word(1) shl s);</div><div class="code_line">&nbsp;&nbsp; &nbsp;end;</div><div class="code_line">&nbsp;&nbsp; &nbsp;if setbit then i := -i;</div><div class="code_line">&nbsp;&nbsp; &nbsp;writeln(i); &nbsp; &nbsp; { В &quot;i&quot; находится целая часть }</div><div class="code_line">end.</div></ol></div></div></div></div>]]></description>
        <author>albom</author>
        <category>Pascal</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=14377&amp;view=findpost&amp;p=121981</guid>
        <pubDate>Fri, 22 Aug 2003 03:51:29 +0000</pubDate>
        <title>Как взять от вещественного числа его целую часть?</title>
        <link>https://forum.sources.ru/index.php?showtopic=14377&amp;view=findpost&amp;p=121981</link>
        <description><![CDATA[albom: Вот это вроде работает:<br>
<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">var</div><div class="code_line">&nbsp;&nbsp; &nbsp;i: longint;</div><div class="code_line">&nbsp;&nbsp; &nbsp;r: single;</div><div class="code_line">const</div><div class="code_line">&nbsp;&nbsp; &nbsp;OneHalf: single = 0.49999998509;</div><div class="code_line">begin</div><div class="code_line">&nbsp;&nbsp; &nbsp;r := 123.9999;</div><div class="code_line">&nbsp;&nbsp; &nbsp;if r = 0 then i := 0</div><div class="code_line">&nbsp;&nbsp; &nbsp;else</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if r &#60; 0 then</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;asm</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fld dword ptr [r]</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fadd dword ptr [OneHalf]</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fistp dword ptr [i]</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;end</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;else</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;asm</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fld dword ptr [r]</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fsub dword ptr [OneHalf]</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fistp dword ptr [i]</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;end;</div><div class="code_line">&nbsp;&nbsp; &nbsp;writeln(i); { В &quot;i&quot; находится целая часть }</div><div class="code_line">end.</div></ol></div></div></div></div>А вообще, в каком-то FAQ`е эта функция была так расписана:<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">; extern &quot;C&quot; int truncate (double x);</div><div class="code_line">_truncate PROC NEAR</div><div class="code_line">PUBLIC &nbsp;_truncate</div><div class="code_line">&nbsp;&nbsp; &nbsp;FLD QWORD PTR [ESP+4] &nbsp; ; x</div><div class="code_line">&nbsp;&nbsp; &nbsp;SUB ESP, 12 &nbsp; &nbsp; ; space for local variables</div><div class="code_line">&nbsp;&nbsp; &nbsp;FIST DWORD PTR [ESP] &nbsp; &nbsp;; rounded value</div><div class="code_line">&nbsp;&nbsp; &nbsp;FST DWORD PTR [ESP+4] &nbsp; ; float value</div><div class="code_line">&nbsp;&nbsp; &nbsp;FISUB DWORD PTR [ESP] &nbsp; ; subtract rounded value</div><div class="code_line">&nbsp;&nbsp; &nbsp;FSTP DWORD PTR [ESP+8] &nbsp;; difference</div><div class="code_line">&nbsp;&nbsp; &nbsp;POP EAX &nbsp; &nbsp; &nbsp; &nbsp; ; rounded value</div><div class="code_line">&nbsp;&nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;POP ECX &nbsp; &nbsp; &nbsp; &nbsp; ; float value</div><div class="code_line">&nbsp;&nbsp; &nbsp;POP EDX &nbsp; &nbsp; &nbsp; &nbsp; ; difference (float)</div><div class="code_line">&nbsp;&nbsp; &nbsp;TEST ECX, ECX &nbsp; &nbsp; &nbsp; ; test sign of x</div><div class="code_line">&nbsp;&nbsp; &nbsp;JS SHORT NEGATIVE</div><div class="code_line">&nbsp;&nbsp; &nbsp;ADD EDX, 7FFFFFFFH &nbsp;; produce carry if difference &#60; -0</div><div class="code_line">&nbsp;&nbsp; &nbsp;SBB EAX, 0 &nbsp; &nbsp; &nbsp;; subtract 1 if x-round(x) &#60; -0</div><div class="code_line">&nbsp;&nbsp; &nbsp;RET</div><div class="code_line">NEGATIVE:</div><div class="code_line">&nbsp;&nbsp; &nbsp;XOR ECX, ECX</div><div class="code_line">&nbsp;&nbsp; &nbsp;TEST EDX, EDX</div><div class="code_line">&nbsp;&nbsp; &nbsp;SETG CL &nbsp; &nbsp; &nbsp; &nbsp; ; 1 if difference &#62; 0</div><div class="code_line">&nbsp;&nbsp; &nbsp;ADD EAX, ECX &nbsp; &nbsp; &nbsp; &nbsp;; add 1 if x-round(x) &#62; 0</div><div class="code_line">&nbsp;&nbsp; &nbsp;RET</div><div class="code_line">_truncate ENDP</div></ol></div></div></div></div>]]></description>
        <author>albom</author>
        <category>Pascal</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=14377&amp;view=findpost&amp;p=121980</guid>
        <pubDate>Thu, 21 Aug 2003 19:37:31 +0000</pubDate>
        <title>Как взять от вещественного числа его целую часть?</title>
        <link>https://forum.sources.ru/index.php?showtopic=14377&amp;view=findpost&amp;p=121980</link>
        <description><![CDATA[Mixxx: Спасибо а по другому нельзя (без str)?<br>А то получается что str - волшебная функция которую реализовать самому нереально?]]></description>
        <author>Mixxx</author>
        <category>Pascal</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=14377&amp;view=findpost&amp;p=121979</guid>
        <pubDate>Thu, 21 Aug 2003 18:01:21 +0000</pubDate>
        <title>Как взять от вещественного числа его целую часть?</title>
        <link>https://forum.sources.ru/index.php?showtopic=14377&amp;view=findpost&amp;p=121979</link>
        <description><![CDATA[albom: Ну и напомню, что trunc(-123.456)=-123, а не -124.]]></description>
        <author>albom</author>
        <category>Pascal</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=14377&amp;view=findpost&amp;p=121978</guid>
        <pubDate>Thu, 21 Aug 2003 17:58:28 +0000</pubDate>
        <title>Как взять от вещественного числа его целую часть?</title>
        <link>https://forum.sources.ru/index.php?showtopic=14377&amp;view=findpost&amp;p=121978</link>
        <description><![CDATA[albom: Попробуй так:<br>
<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">var</div><div class="code_line">&nbsp;&nbsp; &nbsp;e: real;</div><div class="code_line">&nbsp;&nbsp; &nbsp;s: string;</div><div class="code_line">&nbsp;&nbsp; &nbsp;k,v: integer;</div><div class="code_line">begin</div><div class="code_line">&nbsp;&nbsp; &nbsp;e := 123.39; &nbsp; &nbsp;{ Это наше число }</div><div class="code_line">&nbsp;&nbsp; &nbsp;if e = 0 then s := &#39;0&#39;</div><div class="code_line">&nbsp;&nbsp; &nbsp;else</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if e &#60; 0 then str(e+0.5:0:0, s)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;else str(e-0.5:0:0, s);</div><div class="code_line">&nbsp;&nbsp; &nbsp;val(s, v, k);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;if k = 0 then writeln(&#39;Целая часть: &#39;,v)</div><div class="code_line">&nbsp;&nbsp; &nbsp;else writeln(&#39;Ошибка&#39;);</div><div class="code_line">end.</div></ol></div></div></div></div>]]></description>
        <author>albom</author>
        <category>Pascal</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=14377&amp;view=findpost&amp;p=121975</guid>
        <pubDate>Thu, 21 Aug 2003 09:12:00 +0000</pubDate>
        <title>Как взять от вещественного числа его целую часть?</title>
        <link>https://forum.sources.ru/index.php?showtopic=14377&amp;view=findpost&amp;p=121975</link>
        <description><![CDATA[Mixxx: Привет All<br>Мне нужно написать функцию trunc<br>тоесть взять от вещественного числа его целую часть.<br>Какие будут идеи?<br>PS Пользоваться int и frac нельзя<br>PSS Желательно на чистом паскале (без asm вставок)<br>]]></description>
        <author>Mixxx</author>
        <category>Pascal</category>
      </item>
	
      </channel>
      </rss>
	