8000 GitHub - xnought/string-add: Add two very big numbers (string representations)
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

xnought/string-add

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

string-add

Add arbitrarily long numbers together

First compile the zig program

zig build

Then run the executable

./zig-out/bin/string-add 9999991313123123 390840948290482304823048

which produces stdout as 390840958290473617946171 as the answer.

Adding two big numbers

./zig-out/bin/string-add 99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999130712983127661371419087409173490187491807490812749812749081734091827421908749801274098123740981237409182374019274019211111111111111111111111111111111111000000000000000000000000000000000000000000

produces

10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000099999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999130712983127661371419087409173490187491807490812749812749081734091827421908749801274098123740981237409182374019274019211111111111111111111111111111111110999999999999999999999999999999999999999999

Example with files

Take the number in a.txt (500 digits long) and add to b.txt (800 digits long) to produce c.txt as the a + b = c.

cd example
../zig-out/bin/string-add $(cat a.txt) $(cat b.txt) > c.txt

About

Add two very big numbers (string representations)

Resources

License

Stars

Watchers

Forks

Languages

0