<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; CMD/BAT: Математические функции]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=11612</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=11612&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «CMD/BAT: Математические функции».]]></description>
		<lastBuildDate>Fri, 20 May 2016 11:33:52 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[CMD/BAT: Математические функции]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=103987#p103987</link>
			<description><![CDATA[<div class="codebox"><pre><code>
rem Вывод числа без знака %1-Число %2-Вывод
:sint2uint
setlocal enabledelayedexpansion
set i=%1
if &quot;!i:~0,1!&quot;==&quot;-&quot; (
	rem Converting Signed int to Unsigned invert sign and add 2147483648
	rem Use big integer Cmd is not use Real Unsigned integer
	rem 21474,83648
	set /a &quot;u=i ^ 0x80000000&quot;
	set /a &quot;a1=((u %% 100000) + 83648) %% 100000&quot;
	set /a &quot;r1=((u %% 100000) + 83648) / 100000&quot;
	set /a &quot;b1=((u / 100000) %% 100000) + 21474 + r1&quot;
	set a1=00000!a1!
	set i=!b1!!a1:~-5!
)
endlocal&amp;set %2=%i%
goto :eof

rem Преобразование числа в IEEE-754 формат %1-Число %2-Деление на степень двойки %3-Вывод
:int2single
setlocal
	set f=0
	set s=0
	if &quot;%1&quot;==&quot;0&quot; goto int2single_end
	if &quot;%1&quot;==&quot;&quot; goto int2single_end
	set exp=127
	set mlen=%2
	set n=%1
	if !n! lss 0 set s=1&amp;set /a &quot;n=-n&quot;
	for /l %%i in (1,1,!mlen!) do (
		set /a &quot;dp=(n &gt;&gt; (mlen+1))&quot;
		if !dp! neq 0 set /a &quot;n=n &gt;&gt; 1&quot;,&quot;exp+=1&quot;
	)
	for /l %%i in (1,1,!mlen!) do (
		set /a &quot;d=(n &gt;&gt; mlen) &amp; 1&quot;
		if !d!==0 set /a &quot;n=n &lt;&lt; 1&quot;,&quot;exp-=1&quot;
	)
	set /a &quot;f=F | (exp &lt;&lt; 23)&quot;
	set /a &quot;f=F | ((n &amp; ((1 &lt;&lt; mlen)-1)) &lt;&lt; (23-mlen))&quot;
	set /a &quot;f=F | (s &lt;&lt; 31)&quot;
	:int2single_end
endlocal&amp;set %3=%f%
goto :eof
</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (torus)]]></author>
			<pubDate>Fri, 20 May 2016 11:33:52 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=103987#p103987</guid>
		</item>
	</channel>
</rss>
