#Improving BigInteger algorithms

60 messages · Page 1 of 1 (latest)

cosmic pine
crystal thunderBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

trim tundra
cosmic pine
#

this must be improved anyway

trim tundra
#

there are better ways of doing that IIRC, don't remember what exactly they were

cosmic pine
#

yeah i need help finding better algorithms

trim tundra
#

division of bigints is O(n), so repeated division by ten is O(n^2) no matter how it is done

cosmic pine
#

multiplication is also not the best, it's basically long division

trim tundra
#

I think python had this problem so they decided to add an arbitrary cap to how long stringified numbers will be

cosmic pine
#

stupid

#

Improving BigInteger algorithms

#

so I know about the Karatsuba multiplication algorithm but it's more difficult to implement with how my structure stores data

#

I don't know about division or stringification

#

those are the main points i need to improve

blazing cypress
#

Looking through boost multiprecision they just divide by 10, but to print 999^999 takes very small amount of time, didn't measure it but less than a second for 3000+ charachter string

spiral rock
#

it might be useful to poke around in here: https://github.com/bluescarni/mppp/blob/master/include/mp%2B%2B/rational.hpp#L957-L1117

i've never dug into these types of libraries in detail, but it's something i plan on doing eventually. going off of some of the comments in there it seems like they're approaching some of these multiprecision operators in a similar way as gnu's GMP library. both are probably really good codebases to help identify performant algorithm examples to go off of.

cosmic pine
blazing cypress
spiral rock
cosmic pine
#

huh

steel plank
#

for example 234 can be represented as 210^2+310^1+4*10^0

heavy hazel
#

if you already know the factors then you could just output those directly

steel plank
#

yes, i just mean it say that since you can treat numbers as polynomial, you can use fft or other type of transforms for big int operations

lean pagoda
#

I personally used a std::string for bigint operations once

wet fox
#

what value is there in ever having a base 10 string of more than a dozen digits.... humans are the only ones reading base 10.. and they don't bother to read beyond a dozen digits.

blazing cypress
lean pagoda
#

As for why, probably big calculations

#

Human population is getting larger than max uint I believe

blazing cypress
lean pagoda
#

I'm just saying numbers are catching up to the limits

blazing cypress
#

Yeah a uint really isn't that big in the grand scheme of things

lean pagoda
#

Discord/Twitter snowflakes are also uint64

#

Which means eventually these will run out

blazing cypress
lean pagoda
#

Like user ids

#

Channel ids

#

etc

blazing cypress
#

It will be a long time until there are 18,446,744,073,709,551,615 id's for example if my computer was running at full tilt 5.2 GHz, it would take 161984 years to fill up a uint64_t. And there certainly aren't that many ID's being made on twitter per second

wet fox
cosmic pine
lean pagoda
cosmic pine
#

(aliens)

#

duh

wet fox
#

have you been asleep the last year... there's this thing called chatgpt

lean pagoda
#

It's not a living being

wet fox
lean pagoda
# wet fox so?

Let me rephrase the statement:
"Humans are the only living beings that can read anyting"

#

Because by your logic std::istream is also a candidate

cosmic pine
cosmic pine
#

but im not sure i can use it