How can computers even into primes?

The largest known prime has over 22 million digits. In the languages I checked, a long variable can hold like 19 digits. Then how the fuck can there be an app that works with values that have 22 million digits? What language would allow me to implement this and how hard would it be?

Other urls found in this thread:

mersenne.org/primes/
twitter.com/SFWRedditVideos

I only have experience with Java for this, but the BigInteger type can hold arbitrary-length integers.

You lose hardware accelerated arithmetic, but it works.

Can it hold a 22 million digit signed number? What about unsigned ones?

>expecting java to have unsigned number types
dohoho

But yeah, you can represent any number so long as you have the memory for it.

For C and C++ you can use GMP.

How it works is for numbers longer than what the computer can actually store, it cuts them into two separate numbers and keeps them logically linked together. So for example say our computer only supports 4 digits and we want to store 10001, it created two separate numbers which will be 100 and 01 or something like that. When the second number gets to 99 and increments by one, the second number will reset to 0 and the first number will get incremented by one. So 100 99 become 101 00. When the full number gets printed it just concatenates the two together. Make sense?

why dont we build 1MB architectures for this...

My point is that the types of a language are irrelevant when storing a Very Large Number

I thought about something like that before making the thread, but that's bullshit. If for example, you wanted to use the modulus to verify that a number is prime, you couldn't do that operation to the n groups instead and get an equivalent result (there is no rule saying that any group of digits from a prime are also prime, or otherwise). Breaking it in groups might only work for adding and subtracting, but for other operations the computer will need to handle the whole number won't it? Then it's not only a matter of displaying it.

You CAN divide a number represented like that not just adding and subtracting

They save it on a notepad, it's the only program know to man that is powerful enough to hold large numbers.

Nah dude I call bullshit. I'm no mathematician but that shit sounds too magical to be possible.

I also thought something like this (since the website said something about using disk space), but I remembered that when I was younger I tried to randomly generate all possible combinations on a notepad file and it grew enough to fill my 75 GB hard drive in just a couple weeks. I can't imagine it would be done that way, also you still need to hold the number in RAM to do operations; What then?

>not using PiFS to store data

You can deal with massive numbers in a program by storing them into dynamic arrays or other types of data structures, and writing functions for those structures to properly apply an operation to it. I don't know what kind of structures they use in cutting edge software, but in entry level C++ classes at my college we were doing basic arithmetic on massive sized numbers stored as dynamic arrays. I'm sure some math wizard has a more efficient structure to do it.

The numbers are stored as strings instead. Any math performed will be like doing it long-hand by a human.

A char is 1 byte, so one megabyte can be a single "number" with about a million digits, one Gigabyte could be a number with about a billion digits.

Like
said, you lose hardware acceleration so it's really slow, but doable.

When did this board become so fucking dense? Did you all fail highschool math?

To answer OP: many languages have built-in bignums or at least well-supported libraries. But writing your own is trivial if you understand the first thing about math and programming.

use the integer type in haskell

but doesnt all that go out the window when dealing with prime numbers?

Lol. Literally 2nd year comp sci.

Because the methods used to store those long numbers use factoring or something?

You are so fucking retarded

>ad hominem

Only people who know what we are talking about can post ITT. Go look for attention elsewhere.

I'm out of my league discussing memory operations, but in grade school didn't you perform operations on long numbers one digit at a time?

4942 / 2 =
4900/2 = 2400(+100/[r]2) + 42/2 = 21
= 2471

Could that not be scaled to binary operations?

>A char is 1 byte
uhh
They could go with 4-byte BCDs

...are you retarded?

**did you know you can add 32bit numbers together using 8bit registers?**

One easy way of dividing would be repeatedly subtracting

Obviously they used a whiteboard for the large primes.

It was an example on how it could be done simple user, not that it's the only way or that it'd be the most memory efficient way.

Binary coded decimals. Basically numbers stored as strings.

What languages have support for a fraction type? Like a float but arbitrary precision, and only representing quotients instead of all reals.

Lisp

mersenne.org/primes/

There are arbitrary precision programming languages such as bc as well as arbitrary precision libraries for regular programming languages.

This is basic computer science

You literally get projects in your early classes as homework assignments getting you to multiply / divide with using for loops

You can just store it in multiple parts in two longs.