Advertisement
GlobalAccessSoftware

exponential_powers.bat

Nov 16th, 2023
874
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 0.90 KB | Software | 0 0
  1.  
  2.  
  3. ::: RC8
  4.  
  5.   if not defined vers set vers=v8.5.7.84
  6.  
  7. ::: SAMPLE USAGE and Function
  8. ::: set /a base=10 & set /a exponent=5
  9. ::: set fn="%bats%\exponential_powers.bat"
  10. ::: call %fn% answer %baseNum% %exponent%
  11. ::: echo . & echo The Answer for 10\5 is: %answer%.
  12. ::: echo . & pause & echo .
  13.  
  14. ::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  15. :powers <intVar rslt, intVar base, intVar expo>
  16.   setlocal
  17.   set rslt=%~1 & set base=%~2
  18.   set expo=%~3 & set /a answ=1
  19.   for /l %%n in (1, 1, %expo%) do (
  20.     if %answ% gtr 2147483647 pause & break
  21.     if %answ% leq 0 pause & break
  22.     set /a answ*=%base%
  23.     )
  24.   if %answ% gtr 2147483647 (
  25.     goto oops ) else (
  26.       if %answ% leq 0 goto oops )
  27. :end
  28.   endlocal & set %~1=%answ%
  29.   exit /b %errorlevel%
  30. ::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  31.  
  32. :oops
  33.   set answ=That number is out of range.
  34.   goto end
  35.  
  36.  
  37.   :::  100%  -JpE-
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement