Remove leading zeros in batch file

后端 未结 4 1626
逝去的感伤
逝去的感伤 2020-12-05 23:57

In my application, I get a number having leading zeros. I am trying to trim the leading zeros and get the actual number. I tried using /a switch which considers

4条回答
  •  独厮守ぢ
    2020-12-06 00:29

    The exit command is pretty good at clearing leading zeros:

    >set n=0000890
    
    >cmd /c exit /b %n%
    
    >echo %errorlevel%
    890
    

    With this you can use number up to 32 bit integer limit and the piece of code is really small, despite additional call of cmd.exe could harm the performance.

提交回复
热议问题