ahoj, potřebuju pomoct s hledáním chyby v
@echo off
REM *** Jednoduchý příklad využití dávek
REM *** Autor: Michal Blažek (mujweb.cz/www/dosms/)
:zacatek
color 35
echo Obvody geometrickych utvaru
echo ===========================
echo C - ctverce
echo O - valce
echo K - Konec davky
echo Zadejte pismeno obrazce, jehoz obvod chcete vypocitat:
set /p vyber=
set ctverec=C
set valec=O
set finite=K
if /i %vyber%==%ctverec% goto octverce
if /i %vyber%==%finite% goto konec2
if /i %vyber%==%valec% goto oobdelniku else goto konec
REM *** Přepínač /i znamená, že podmínka nebude rozlišovat malá a velká
REM *** písmena. V tomto příkladu vzácně můžet použít tradiční operátor ==
:octverce
color 42
echo Obvod ctverce
echo =============
set /p stranaA=Zadejte velikost strany a:
echo vzorec: o = a . a
echo a = %stranaA%
echo _________________
echo .
set /a "vysledek1=stranaA*stranaA"
echo o = a . a = %stranaA% . %stranaA% = %vysledek1%
echo .
pause
goto konec2
:oobdelniku
color 75
echo Povrch valce
echo ===============
set /p polomer=Zadejte velikost polomeru r:
set /p vyska=Zadejte velikost vysky v:
echo vzorec: S = 2.pi.r(r+v)
echo r = %polomer%
echo v = %vyska%
echo _________________
echo .
set /a "vysledek2=2*3,14*%polomer%*(%polomer%+%vyska%)"
echo S = 2 . 3,14 . %polomer% . (%polomer% + %vyska%) = %vysledek2%
echo .
pause
goto Konec2
:konec
color 67
echo Toto pismeno neznam. Nyni stisknete libovolnou klavesu pro navrat do
hlavni nabidky
:konec2
výsledek povrchu válce mi vždy vyjde 6
Fórum › Příkazový řádek
Matematika v dávkách

Chyba je na této řádce:
set /a "vysledek2=2*3,14*%polomer%*(%polomer%+%vyska%)"
Protože čárka v desetinném čísle 3,14 je brána jako nějaký ukončovač či co. Každopádně to znamená, že hodnotou proměnné vysledek2 vždy bude šestka (tudíž výsledek součinu 2*3).
Větší starost mi ovšem dělá to, že až teď jsem zjistil, že dávkové soubory neumí počítat s desetinými čísly, tudíž i když bych pí napsal ve tvaru (314/100), tak by se zaokrouhlilo podle pravidel dolů, takže to mi dělá větší starosti.
Tuto chybu na webových stránkách samozřejmě, co nejdříve opravim a děkuji za upozornění.

Přidej příspěvek
Toto téma je starší jak čtvrt roku – přidej svůj příspěvek jen tehdy, máš-li k tématu opravdu co říct!
Ano, opravdu chci reagovat → zobrazí formulář pro přidání příspěvku
×Vložení zdrojáku
×Vložení obrázku
×Vložení videa
Aktuálně jsou podporována videa ze serverů YouTube, Vimeo a Dailymotion.
×






























































Uživatelé prohlížející si toto vlákno
Uživatelé on-line: 0 registrovaných, 15 hostů
Podobná vlákna
Matematika — založil Peter D.
Matematika — založil Michal
MATEMATIKA — založil Tomáš
Matematika — založil joskoo
Matematika — založil David