Sign up
Login
New paste
Home
Archive
English
English
Sign up
Login
New Paste
Browse
@@Echo off :# FormatNum function by T3RRY ; Created: 25th July 2021 :# Purpose: Function to Format numbers up to 1485 digits long with coma's IE: :# 10 = 10 ; 100 = 100 ; 1000 = 1,000 ; 10000 = 10,000 ; 100000 = 100,000 ; 1000000 = 1,000,000 :# -S and -0 switches accepted as third arg to prepend with whitespice or leading zero's respectively. Setlocal EnableExtensions %= Examples =% :# 0 prefixed Call :FormatNum 1532151544621668007951135446231798748995413134278463598153468247 rv[1]1 -0 Call :FormatNum 4071 rv[1]2 -0 Call :FormatNum 20 rv[1]3 -0 Call :FormatNum 3 rv[1]4 -0 Set rv[1] :# Whitespace prefixed Call :FormatNum 1532151544621668007951135446231798748995413134278463598153468247 rv[2]1 -S Call :FormatNum 4071 rv[2]2 -S Call :FormatNum 20 rv[2]3 -S Call :FormatNum 3 rv[3]4 -S Set rv[2] :# No Prefix Call :FormatNum 1532151544621668007951135446231798748995413134278463598153468247 rv[3]1 Call :FormatNum 4071 rv[3]2 Call :FormatNum 20 rv[3]3 Call :FormatNum 3 rv[3]4 Set rv[3] Endlocal Goto :Eof :FormatNum <Int> <ReturnVar> [-0|-S] If not defined FormatDelim Set "FormatDelim=," %= Allow default ',' delim to be overridden =% If /I "%~2"=="-0" Exit /b 3 %= Errorlevel 3 - arg2 incorrectly occuipied by arg3 =% If /I "%~2"=="-S" Exit /b 3 If "%~2"=="" Exit /b 2 %= Errorlevel 2 - arg2 missing =% If "%~1"=="" Exit /b 1 %= Errorlevel 1 - all args missing =% Setlocal EnableDelayedExpansion set "tmp=.%~1" %= No Leading zeros =% If "%~3"=="-0" set "tmp=.00%~1" %= Leading zeros =% If /I "%~3"=="-S" set "tmp=. %~1" %= Leading whitespace =% %= Approximate Max string length as a multiple of 3 to reduce execution time =% For %%i in (1485 918 567 351 216 135 81 54 27 18 9)Do If "!tmp:~%%i,1!"=="" ( Set /A "Max=%%i" ) For /l %%n in (!Max! -3 0)Do ( For /f "Delims=" %%o in ('Set /A %%n+3')Do If not "%%n"=="0" ( set "Size=!Size!%FormatDelim%!tmp:~-%%o,-%%n!" )Else set "Size=!Size!%FormatDelim%!tmp:~-3!" ) %= iterations below are required to remove all paired comas. =% For /l %%i in (0 1 8)Do set "Size=!Size:%FormatDelim%%FormatDelim%=%FormatDelim%!" %= remove excess leading chars =% set "Size=!Size:~1!" set "Size=!Size:.00%FormatDelim%=!" set "Size=!Size:.0%FormatDelim%=!" set "Size=!Size:. %FormatDelim%=!" set "Size=!Size:. %FormatDelim%=!" set "Size=!Size:.%FormatDelim%=!" set "Size=!Size:.=!" Endlocal & Set "%~2=%Size%" Exit /B 0 :# FormatNum function by T3RRY ; Created: 25th July 2021 :# Purpose: Function to Format numbers up to 1485 digits long with coma's IE: :# 10 = 10 ; 100 = 100 ; 1000 = 1,000 ; 10000 = 10,000 ; 100000 = 100,000 ; 1000000 = 1,000,000 :# -S and -0 switches accepted as third arg to prepend with whitespice or leading zero's respectively. Setlocal EnableExtensions %= Examples =% :# 0 prefixed Call :FormatNum 1532151544621668007951135446231798748995413134278463598153468247 rv[1]1 -0 Call :FormatNum 4071 rv[1]2 -0 Call :FormatNum 20 rv[1]3 -0 Call :FormatNum 3 rv[1]4 -0 Set rv[1] :# Whitespace prefixed Call :FormatNum 1532151544621668007951135446231798748995413134278463598153468247 rv[2]1 -S Call :FormatNum 4071 rv[2]2 -S Call :FormatNum 20 rv[2]3 -S Call :FormatNum 3 rv[3]4 -S Set rv[2] :# No Prefix Call :FormatNum 1532151544621668007951135446231798748995413134278463598153468247 rv[3]1 Call :FormatNum 4071 rv[3]2 Call :FormatNum 20 rv[3]3 Call :FormatNum 3 rv[3]4 Set rv[3] Endlocal Goto :Eof :FormatNum <Int> <ReturnVar> [-0|-S] If not defined FormatDelim Set "FormatDelim=," %= Allow default ',' delim to be overridden =% If /I "%~2"=="-0" Exit /b 3 %= Errorlevel 3 - arg2 incorrectly occuipied by arg3 =% If /I "%~2"=="-S" Exit /b 3 If "%~2"=="" Exit /b 2 %= Errorlevel 2 - arg2 missing =% If "%~1"=="" Exit /b 1 %= Errorlevel 1 - all args missing =% Setlocal EnableDelayedExpansion set "tmp=.%~1" %= No Leading zeros =% If "%~3"=="-0" set "tmp=.00%~1" %= Leading zeros =% If /I "%~3"=="-S" set "tmp=. %~1" %= Leading whitespace =% %= Approximate Max string length as a multiple of 3 to reduce execution time =% For %%i in (1485 918 567 351 216 135 81 54 27 18 9)Do If "!tmp:~%%i,1!"=="" ( Set /A "Max=%%i" ) For /l %%n in (!Max! -3 0)Do ( For /f "Delims=" %%o in ('Set /A %%n+3')Do If not "%%n"=="0" ( set "Size=!Size!%FormatDelim%!tmp:~-%%o,-%%n!" )Else set "Size=!Size!%FormatDelim%!tmp:~-3!" ) %= iterations below are required to remove all paired comas. =% For /l %%i in (0 1 8)Do set "Size=!Size:%FormatDelim%%FormatDelim%=%FormatDelim%!" %= remove excess leading chars =% set "Size=!Size:~1!" set "Size=!Size:.00%FormatDelim%=!" set "Size=!Size:.0%FormatDelim%=!" set "Size=!Size:. %FormatDelim%=!" set "Size=!Size:. %FormatDelim%=!" set "Size=!Size:.%FormatDelim%=!" set "Size=!Size:.=!" Endlocal & Set "%~2=%Size%" Exit /B 0
Paste Settings
Paste Title :
[Optional]
Paste Folder :
[Optional]
Select
Syntax Highlighting :
[Optional]
Select
Markup
CSS
JavaScript
Bash
C
C#
C++
Java
JSON
Lua
Plaintext
C-like
ABAP
ActionScript
Ada
Apache Configuration
APL
AppleScript
Arduino
ARFF
AsciiDoc
6502 Assembly
ASP.NET (C#)
AutoHotKey
AutoIt
Basic
Batch
Bison
Brainfuck
Bro
CoffeeScript
Clojure
Crystal
Content-Security-Policy
CSS Extras
D
Dart
Diff
Django/Jinja2
Docker
Eiffel
Elixir
Elm
ERB
Erlang
F#
Flow
Fortran
GEDCOM
Gherkin
Git
GLSL
GameMaker Language
Go
GraphQL
Groovy
Haml
Handlebars
Haskell
Haxe
HTTP
HTTP Public-Key-Pins
HTTP Strict-Transport-Security
IchigoJam
Icon
Inform 7
INI
IO
J
Jolie
Julia
Keyman
Kotlin
LaTeX
Less
Liquid
Lisp
LiveScript
LOLCODE
Makefile
Markdown
Markup templating
MATLAB
MEL
Mizar
Monkey
N4JS
NASM
nginx
Nim
Nix
NSIS
Objective-C
OCaml
OpenCL
Oz
PARI/GP
Parser
Pascal
Perl
PHP
PHP Extras
PL/SQL
PowerShell
Processing
Prolog
.properties
Protocol Buffers
Pug
Puppet
Pure
Python
Q (kdb+ database)
Qore
R
React JSX
React TSX
Ren'py
Reason
reST (reStructuredText)
Rip
Roboconf
Ruby
Rust
SAS
Sass (Sass)
Sass (Scss)
Scala
Scheme
Smalltalk
Smarty
SQL
Soy (Closure Template)
Stylus
Swift
TAP
Tcl
Textile
Template Toolkit 2
Twig
TypeScript
VB.Net
Velocity
Verilog
VHDL
vim
Visual Basic
WebAssembly
Wiki markup
Xeora
Xojo (REALbasic)
XQuery
YAML
HTML
Paste Expiration :
[Optional]
Never
Self Destroy
10 Minutes
1 Hour
1 Day
1 Week
2 Weeks
1 Month
6 Months
1 Year
Paste Status :
[Optional]
Public
Unlisted
Private (members only)
Password :
[Optional]
Description:
[Optional]
Tags:
[Optional]
Encrypt Paste
(
?
)
Create New Paste
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login
Site Languages
×
English
Do you like cookies?
🍪 We use cookies to ensure you get the best experience on our website.
Learn more
I agree