How to store extremely big numbers?

Sorry if this needs to go to sticky.
How do you store, say, 10e250 on a variable in $language? AFAIK the maximum for 64-bit integers is 2^64-1, and that's for unsigned. So can you store a number that big? If you can, then how?
The propetriary game Adventure Capitalist reaches numbers up to 10e350.

Other urls found in this thread:

gmplib.org
en.wikipedia.org/wiki/Rule_110
en.wikipedia.org/wiki/Turing_tarpit
wtfpl.net/
twitter.com/AnonBabble

Do you need unit accuracy or can you settle for storing just the exponent past a certain threshold?

gmplib.org

There are libraries that can handle it (with a performance hit). Look at source for details, but tldr = use many integers.

just truncate it. nobody will notice.

libtommath

It doesn't use harmful licenses

store the high order bits and low order bits in two separate variables

in C that would look like this:

typedef struct big_number { unsigned long long high; unsigned long long low; } big_number;

m8

GMP or do it yourself by implementing the long math algorithms in Knuth's book.

...

I just had a thought on what would happen if my post numbers were to hit that in my imageboard software, and I feel uncomfortable.

Thanks OP, and fuck you PHP.

For your post numbers to hit 10e150 every human in this planet needs to make 10e140 posts (assuming 10 billion people exist atm)

What are YOU working on btw? I'm working on Blazechan.
Saged for no double bump.

I'm working on Haruko / 314chan. Going pretty well for code made by a kid who died of cancer.

Well that gives me faith lol

Just imagine what post numbers would look like though lmao

100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 GET?

Sage got stuck

...

1. I doubt the numbers would ever reach that high
2. PHP, like any turing-complete programming language, can do arbitrary precision arithmetic.

Being Turing-complete only means that any calculation that you'd use arbitrary precision arithmetic for can be performed or simulated in some way, not that it's at all practical.

Right, but arbitrary precision arithmetic is not difficult to implement on integers and that's assuming there are no libraries to do that task, which there are.

I'm protesting the "turing-complete" thing. It's hardly relevant. How many programming languages can you name that aren't turing-complete?

It's relevant in that it means that even if there were no libraries for it, you could do it yourself.

This. In a way C isn't really turing complete because you cannot really do much in it without using a library (printing to screen, sleeping, nanosleeping, keyboard capture, etc.)
I might be wrong though.

>I might be wrong though.
You are: turing completeness refers to the ability to do anything computable; access to hardware isn't touched on at all since turing machines are way out there in the world of theoretical computing

Ah. I see. It's about doing everything in arithmetic rather than just doing everything.

This thing is Turing-complete:
en.wikipedia.org/wiki/Rule_110

It's a very basic property of a system. It means that there is some way to perform any calculation that you could perform in other Turing-complete systems. It means that you can technically implement arbitrary precision arithmetic, but it doesn't guarantee that it's any easier than implementing arbitrary precision arithmetic in CSS.

So many things are Turing-complete that calling PHP Turing-complete isn't interesting, and being Turing-complete only guarantees that something is technically possible, not that it's easy or practically feasible.

And for that we have the term "turing tarpit" a term used by Alan Perlis in Epigrams on Programming

54. Beware of the Turing tar-pit in which everything is possible but nothing of interest is easy

Something like Brainfuck is an example of a turing tarpit.

en.wikipedia.org/wiki/Turing_tarpit

no user, we aren't buying into your black-and-white politics. fuck off

wtfpl is a permissive license. I haven't heard anyone deny that before. Do you know what a permissive license is?

Yeah, it's a term used as a slur by freetards on one side and as a marketing buzzword on the other side

I suggest you go back and re-read that post until you fully understand the meaning of it (hint: fuck off)

Even the wtfpl site calls the wtfpl permissive:
wtfpl.net/

put them in yo momma's pocket

search 'bignum' op

wtfpl is not even a license but public domain. It's free btw.

It's a license (that's why it has "license" in its name) and it doesn't really put things in the public domain, although it gives comparable permissions.

And do that with a linked list instead and you got infinite numbers

for what purpose? there's no advantage a linked list provides for this task, and there are significant disadvantages over using an array (performance, memory footprint, heap fragmentation, lack of cache coherence, many free calls per integer on destruction).

Make a mp library. Use gmp and print the fucking number in ascii

he seriously died of cancer? as far as i know, he left polish chans after a heavy drama at that time. my experience with him was far from smooth, he had 15 years at that time and heavy emotional problems. he had some knowledge, but was a nuissance to deal with.

WTFPL is a permissive license. it's not public domain, but it's close to being equivalent. it's not recommeded, because it doesn't contain a "NO WARRANTY" clause making the software maker legally responsible for the code he wrote (at least in US). public domain laws vary between countries, that's why it's not recommended to use it directly.

FUCK

fuck off

FUCK

f

uck off

Except 32-bit float can only represent about 4 billion numbers.