anonymity
2010-10-05 16:37:57
Long int? How would one go about reading/using/computing/printing a long int? Ex: integer with 30,000 numbers to it.
How could that be achieved? Reading such a large number in and being able to send back a possibly much larger one? Say, up to 100k + numbers to it.
My first thought was converting whatever was read in and holding it as binary to work with.
thoughts? ideas? anyone done this before?
E: I am looking to read, compute with, and print a long int; manually 20-100,000 numbers.
Quickmarch
2010-10-05 16:54:00
Not completely sure but it's probably 'uint'.
Feroc1ty
2010-10-05 17:10:20
most efficient method would be making it only accurate to first few places, and rest making it a calculation of power of 10 the number is
anonymity
2010-10-05 17:22:01
Quickmarch, I was curious how to do something like this manually.
Feroc1ty, thanks but I am still looking on how to do this.
I am looking to read, compute with, and print a long int; manually 20-100,000 numbers.
Feroc1ty
2010-10-05 18:04:52
what do you mean.. you could use a string, but that uses 8 bits for only one spot, so a custom class with an array of bools assuming they use 1 bit (depending on compiler) wud be best
anonymity
2010-10-07 19:31:05
@ Quickmarch - Thanks for that. :) however, I am looking on how to do this manually not using a library.
@ Feroc1ty - Yea, that makes sense =]. I guess just might not be being real clear on my question in the first place.
How would I go about reading a long int say up to 50k numbers and then dealing with it in C?
Nava2
2010-10-07 19:36:53
Err, you would have to create your own number style storing it into bits, and then having memory allocated as it grows. Not to mention, you would have to implement your own add subtract etc. Which *is not* that hard, but you would need a lot of knowledge about binary arithmetic. So complements, adding, subtracting, &, |, etc.. It would very well be possible though.
It'd not be easy..
moparisthebest
2010-10-08 00:24:13
It would be better if you could explain to us what you are actually trying to accomplish, there may be a much better way. But as far as dealing with huge numbers, you could do something similar to Java's
BigInteger class.
anonymity
2010-10-11 02:07:13
@ Nava2 - thanks, input welcome!
@ moparisthebest - also thanks!
As for what I am doing, I did get the name wrong. I would be dealing with 'big integers' not long integers. As for the how, converting into nibbles to store and work with is how this looks like it will go.