Article 6NPV4 Making a Bignum Library for Fun

Making a Bignum Library for Fun

by
hubie
from on (#6NPV4)

owl writes:

https://austinhenley.com/blog/bignum1.html

What happens when numbers get too big for a computer to work with?

For example, a 64-bit unsigned integer can be as large as 18,446,744,073,709,551,615. That is... huge. But what if it isn't enough?

Enter bignums, or arbitrary-precision numbers. These very, very large numbers allow you to go beyond CPU limitations for representing integers and performing arithmetic, limited only by the computer's memory.

If you open up Python and throw some really, really big numbers at it, you'll see that it works without any issue. Although C requires using a library for bignums, Python supports them right out of the box. In fact, you can use big numbers and small numbers interchangeably and it is completely abstracted away from the programmer.

I've always wanted to know how these bignum libraries work, so this is my adventure in learning about them.

The irony with this blog post, for any of us who did any assembly programming on the old 8-bit microprocessors (8080/Z80/6502/6800), is that doing "big-nums" was a required bit of knowledge to do any math larger than 8-bits wide (6502) or 16-bits wide (for a few instructions on the 8080/Z80/6800). The blog writer must be one of today's Ten Thousand.

Original Submission

Read more of this story at SoylentNews.

External Content
Source RSS or Atom Feed
Feed Location https://soylentnews.org/index.rss
Feed Title
Feed Link https://soylentnews.org/
Reply 0 comments