uma simples pergunta. Batch Script faz conta com números decimais?? se sim como?
Batch-Satti
Você não está conectado. Conecte-se ou registre-se
Pssn gosta desta mensagem
@echo off
title DIVISAO CON DECIMAIS
echo Calcula uma DIVISAO com numeros DECIMAIS
:main
echo.
echo.
echo.
set did=
set div=
set max=
set /p did=Introduza o dividendo:
set /p div=Introduza o divisor:
set /p max=Introduza o numero maximo de DECIMAIS (defalt 30):
if "%did%"=="" goto main
if "%div%"=="" goto main
if "%max%"=="" set max=30
if "%max%"=="0" set max=30
set /a xxx=%did%*1
if not "%xxx%"=="%did%" goto main
set /a xxx=%div%*1
if not "%xxx%"=="%div%" goto main
set /a xxx=%max%*1
if not "%xxx%"=="%max%" goto main
echo.
if %div%==0 (
echo Erro. DIVISAO por zero.
pause>nul
exit
)
set /a divno0=%did%/%div%
set /a mult1=%divno0%*%div%
set /a resi0=%did%-%mult1%
if %resi0%==0 (
goto exato
)
set p=0
echo Calculando...
echo.
:a
set /a nu=nu+1
set temp1=resi%p%
set temp2=divno%nu%
set temp3=mult%nu%
call:func1 %%%temp1%%%0
call:func2 %%%temp2%%% %%%temp2%%%
call:func3 %%%temp1%%%0 %%%temp3%%%
goto sig
:func1
set /a divno%nu%=%1/%div%
goto:EOF
:func2
set /a mult%nu%=%1*%div%
goto:EOF
:func3
set /a resi%nu%=%1-%2
goto:EOF
:sig
set /a p=p+1
set temp=resi%nu%
call:funcao2 %%%temp%%%
goto sig2
:funcao2
set tempvalor=%1
goto:EOF
:sig2
If not %nu%==%max% if not %tempvalor%==0 goto a
For /L %%I IN (1,1,%nu%) DO (
call:funcao3 %%%%divno %%I%%%%
)
goto exato
:funcao3
call:funcao7 %1%2
goto seguir
:funcao7
set tmpvar=%1
goto:EOF
:seguir
set decimal=%decimal%%tmpvar%
goto:EOF
:exato
if not "%decimal%"=="" set decimal=.%decimal%
echo Resultado: %divno0%%decimal%
pause>nul
exit
Tópicos semelhantes
Permissões neste sub-fórum
Não podes responder a tópicos
|
|