<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; CMD/BAT: Математические функции]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=11612&amp;type=atom" />
	<updated>2016-05-20T11:33:52Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=11612</id>
		<entry>
			<title type="html"><![CDATA[CMD/BAT: Математические функции]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=103987#p103987" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[torus]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33003</uri>
			</author>
			<updated>2016-05-20T11:33:52Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=103987#p103987</id>
		</entry>
</feed>
